-
Notifications
You must be signed in to change notification settings - Fork 22.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live examples using window.open are broken #34350
Comments
We need to add these perms to playground output iframe as well, so hard coding would be more suitable for both. BTW would love to see the deprecated params eliminated from the macro.
The example needs fixing. It is using iframe's location and not the blob page location. Following code with the macro fixed does open the function showViewLiveResultButton() {
if (window.self !== window.top) {
// Ensure that if our document is in a frame, we get the user
// to first open it in its own tab or window. Otherwise, this
// example won't work.
const p = document.querySelector("p");
p.textContent = "";
const button = document.createElement("button");
button.textContent = "View live result of the example code above";
p.append(button);
const blobParts = ['<html><body><h1>hey1</p></body></html>'];
const blob = new Blob(blobParts, { type: "text/html" });
const url = URL.createObjectURL(blob);
button.addEventListener("click", () => window.open(url));
return true;
}
}
showViewLiveResultButton() |
I was suggesting that there can be another parameter to set For context, this "open in separate page" thing was a workaround precisely for CSP settings (#19096 and its linked issues), but based on #29109 it seems this remains an unsolved issue for GH live samples. cc @sideshowbarker may have some good ideas |
Some examples require the live sample code to work on its own page and not in an iframe on the MDN page. Such examples are trying to automatically open live samples in new tab. The issue is if we put live sample URLs directly in a new tab it doesn't work: https://live.mdnplay.dev/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API/runner.html?id=tag_example |
I'm not sure. I think it broke after we migrated to the new live sample system. It probably was working before, because it was specifically implemented to work around CSP settings, so I assume it was working at least when #19096 was made. The best solution is obviously to make these examples work inline without requiring opening an external page. |
The following examples use
window.open
:Error in Chrome:
@OnkarRuikar from Slack (in response to an attempt to add
allow-popups
to the macro argument):Perhaps this can be another parameter? Perhaps we can fix the examples to not use
window.open
anymore? Not sure.(By the way, if you actually paste that URL in a new tab the page is blank, so I suspect it just doesn't work)
The text was updated successfully, but these errors were encountered: