Bug 1114299 - Regression test. r=smaug

This commit is contained in:
Mike Conley 2015-07-17 13:51:39 -04:00
parent caba121b6c
commit d4f0cb3104
3 changed files with 61 additions and 0 deletions

View File

@ -9,3 +9,4 @@ support-files =
[browser_bug343515.js]
skip-if = e10s # Bug ?????? - test directly touches content (tries to QI the content window)
[browser_test-content-chromeflags.js]

View File

@ -0,0 +1,45 @@
const TEST_PAGE = `data:text/html,<html><body><a href="about:blank" target="_blank">Test</a></body></html>`;
const CHROME_ALL = Ci.nsIWebBrowserChrome.CHROME_ALL;
const CHROME_REMOTE_WINDOW = Ci.nsIWebBrowserChrome.CHROME_REMOTE_WINDOW;
/**
* Tests that when we open new browser windows from content they
* get the full browser chrome.
*/
add_task(function* () {
// Make sure that the window.open call will open a new
// window instead of a new tab.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({
"set": [
["browser.link.open_newwindow", 2],
]
}, resolve);
});
yield BrowserTestUtils.withNewTab({
gBrowser,
url: TEST_PAGE
}, function*(browser) {
let openedPromise = BrowserTestUtils.waitForNewWindow();
BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, browser);
let win = yield openedPromise;
let chromeFlags = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow)
.chromeFlags;
// In the multi-process case, the new window will have the
// CHROME_REMOTE_WINDOW flag set.
const EXPECTED = gMultiProcessBrowser ? CHROME_ALL | CHROME_REMOTE_WINDOW
: CHROME_ALL;
is(chromeFlags, EXPECTED, "Window should have opened with all chrome");
BrowserTestUtils.closeWindow(win);
});
});

View File

@ -188,6 +188,21 @@ this.BrowserTestUtils = {
});
},
/**
* Waits for the next browser window to open and be fully loaded.
*
* @return {Promise}
* A Promise which resolves the next time that a DOM window
* opens and the delayed startup observer notification fires.
*/
waitForNewWindow: Task.async(function* (delayedStartup=true) {
let win = yield this.domWindowOpened();
yield TestUtils.topicObserved("browser-delayed-startup-finished",
subject => subject == win);
return win;
}),
/**
* Loads a new URI in the given browser and waits until we really started
* loading. In e10s browser.loadURI() can be an asynchronous operation due