mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1231695 - Don't use contentWindow on remote browsers. r=mccr8
This commit is contained in:
parent
d1ec51370f
commit
a9082c6e3e
@ -5,61 +5,66 @@
|
|||||||
* loads. The policy we are enforcing is outlined here:
|
* loads. The policy we are enforcing is outlined here:
|
||||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=593387#c17
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=593387#c17
|
||||||
*/
|
*/
|
||||||
var newBrowser;
|
|
||||||
|
|
||||||
function test() {
|
add_task(function* test() {
|
||||||
waitForExplicitFinish();
|
yield BrowserTestUtils.withNewTab({ gBrowser,
|
||||||
|
url: "chrome://global/content/mozilla.xhtml" },
|
||||||
|
function* (newBrowser) {
|
||||||
|
// NB: We load the chrome:// page in the parent process.
|
||||||
|
yield testXFOFrameInChrome(newBrowser);
|
||||||
|
|
||||||
var newTab = gBrowser.addTab();
|
// Run next test (try the same with a content top-level context)
|
||||||
gBrowser.selectedTab = newTab;
|
yield BrowserTestUtils.loadURI(newBrowser, "http://example.com/");
|
||||||
newBrowser = gBrowser.getBrowserForTab(newTab);
|
yield BrowserTestUtils.browserLoaded(newBrowser);
|
||||||
//alert(newBrowser.contentWindow);
|
|
||||||
|
|
||||||
newBrowser.addEventListener("load", testXFOFrameInChrome, true);
|
yield ContentTask.spawn(newBrowser, null, testXFOFrameInContent);
|
||||||
newBrowser.contentWindow.location = "chrome://global/content/mozilla.xhtml";
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
function testXFOFrameInChrome() {
|
|
||||||
newBrowser.removeEventListener("load", testXFOFrameInChrome, true);
|
|
||||||
|
|
||||||
|
function testXFOFrameInChrome(newBrowser) {
|
||||||
// Insert an iframe that specifies "X-Frame-Options: DENY" and verify
|
// Insert an iframe that specifies "X-Frame-Options: DENY" and verify
|
||||||
// that it loads, since the top context is chrome
|
// that it loads, since the top context is chrome
|
||||||
|
var deferred = {};
|
||||||
|
deferred.promise = new Promise((resolve) => {
|
||||||
|
deferred.resolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
var frame = newBrowser.contentDocument.createElement("iframe");
|
var frame = newBrowser.contentDocument.createElement("iframe");
|
||||||
frame.src = "http://mochi.test:8888/tests/dom/base/test/file_x-frame-options_page.sjs?testid=deny&xfo=deny";
|
frame.src = "http://mochi.test:8888/tests/dom/base/test/file_x-frame-options_page.sjs?testid=deny&xfo=deny";
|
||||||
frame.addEventListener("load", function() {
|
frame.addEventListener("load", function loaded() {
|
||||||
frame.removeEventListener("load", arguments.callee, true);
|
frame.removeEventListener("load", loaded, true);
|
||||||
|
|
||||||
// Test that the frame loaded
|
// Test that the frame loaded
|
||||||
var test = this.contentDocument.getElementById("test");
|
var test = this.contentDocument.getElementById("test");
|
||||||
is(test.tagName, "H1", "wrong element type");
|
is(test.tagName, "H1", "wrong element type");
|
||||||
is(test.textContent, "deny", "wrong textContent");
|
is(test.textContent, "deny", "wrong textContent");
|
||||||
|
deferred.resolve();
|
||||||
// Run next test (try the same with a content top-level context)
|
|
||||||
newBrowser.addEventListener("load", testXFOFrameInContent, true);
|
|
||||||
newBrowser.contentWindow.location = "http://example.com/";
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
newBrowser.contentDocument.body.appendChild(frame);
|
newBrowser.contentDocument.body.appendChild(frame);
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function testXFOFrameInContent() {
|
function testXFOFrameInContent(newBrowser) {
|
||||||
newBrowser.removeEventListener("load", testXFOFrameInContent, true);
|
|
||||||
|
|
||||||
// Insert an iframe that specifies "X-Frame-Options: DENY" and verify that it
|
// Insert an iframe that specifies "X-Frame-Options: DENY" and verify that it
|
||||||
// is blocked from loading since the top browsing context is another site
|
// is blocked from loading since the top browsing context is another site
|
||||||
var frame = newBrowser.contentDocument.createElement("iframe");
|
var deferred = {};
|
||||||
|
deferred.promise = new Promise((resolve) => {
|
||||||
|
deferred.resolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
var frame = content.document.createElement("iframe");
|
||||||
frame.src = "http://mochi.test:8888/tests/dom/base/test/file_x-frame-options_page.sjs?testid=deny&xfo=deny";
|
frame.src = "http://mochi.test:8888/tests/dom/base/test/file_x-frame-options_page.sjs?testid=deny&xfo=deny";
|
||||||
frame.addEventListener("load", function() {
|
frame.addEventListener("load", function loaded() {
|
||||||
frame.removeEventListener("load", arguments.callee, true);
|
frame.removeEventListener("load", loaded, true);
|
||||||
|
|
||||||
// Test that the frame DID NOT load
|
// Test that the frame DID NOT load
|
||||||
var test = this.contentDocument.getElementById("test");
|
var test = this.contentDocument.getElementById("test");
|
||||||
is(test, undefined, "should be about:blank");
|
is(test, null, "should be about:blank");
|
||||||
|
|
||||||
// Finalize the test
|
deferred.resolve();
|
||||||
gBrowser.removeCurrentTab();
|
|
||||||
finish();
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
newBrowser.contentDocument.body.appendChild(frame);
|
content.document.body.appendChild(frame);
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user