зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1240014, enable test browser_newtab_external_resource in e10s, r=adw
This commit is contained in:
Родитель
a13459489b
Коммит
acbfac05ce
|
@ -14,7 +14,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var browser = null;
|
||||
var aboutNewTabService = Cc["@mozilla.org/browser/aboutnewtab-service;1"]
|
||||
.getService(Ci.nsIAboutNewTabService);
|
||||
|
||||
|
@ -22,7 +21,40 @@ const ABOUT_NEWTAB_URI = "about:newtab";
|
|||
const PREF_URI = "http://example.com/browser/browser/base/content/test/newtab/external_newtab.html";
|
||||
const DEFAULT_URI = aboutNewTabService.newTabURL;
|
||||
|
||||
function testPref() {
|
||||
function* loadNewPageAndVerify(browser, uri) {
|
||||
let browserLoadedPromise = BrowserTestUtils.waitForEvent(browser, "load", true);
|
||||
browser.loadURI("about:newtab");
|
||||
yield browserLoadedPromise;
|
||||
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, { uri: uri }, function* (args) {
|
||||
let uri = args.uri;
|
||||
|
||||
is(String(content.document.location), uri, "document.location should match " + uri);
|
||||
is(content.document.documentURI, uri, "document.documentURI should match " + uri);
|
||||
|
||||
if (uri == "about:newtab") {
|
||||
is(content.document.nodePrincipal,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
"nodePrincipal should match systemPrincipal");
|
||||
}
|
||||
else {
|
||||
is(content.document.nodePrincipal.URI.spec, uri,
|
||||
"nodePrincipal should match " + uri);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
// test the default behavior
|
||||
yield* addNewTabPageTab();
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
|
||||
ok(!aboutNewTabService.overridden,
|
||||
"sanity check: default URL for about:newtab should not be overriden");
|
||||
|
||||
yield* loadNewPageAndVerify(browser, ABOUT_NEWTAB_URI);
|
||||
|
||||
// set the pref for about:newtab to point to an exteranl resource
|
||||
aboutNewTabService.newTabURL = PREF_URI;
|
||||
ok(aboutNewTabService.overridden,
|
||||
|
@ -30,46 +62,13 @@ function testPref() {
|
|||
is(aboutNewTabService.newTabURL, PREF_URI,
|
||||
"sanity check: default URL for about:newtab should return the new URL");
|
||||
|
||||
browser.contentWindow.location = ABOUT_NEWTAB_URI;
|
||||
yield* loadNewPageAndVerify(browser, PREF_URI);
|
||||
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
is(content.document.location, PREF_URI, "document.location should match the external resource");
|
||||
is(content.document.documentURI, PREF_URI, "document.documentURI should match the external resource");
|
||||
is(content.document.nodePrincipal.URI.spec, PREF_URI, "nodePrincipal should match the external resource");
|
||||
// reset to about:newtab and perform sanity check
|
||||
aboutNewTabService.resetNewTabURL();
|
||||
is(aboutNewTabService.newTabURL, DEFAULT_URI,
|
||||
"sanity check: resetting the URL to about:newtab should return about:newtab");
|
||||
|
||||
// reset to about:newtab and perform sanity check
|
||||
aboutNewTabService.resetNewTabURL();
|
||||
is(aboutNewTabService.newTabURL, DEFAULT_URI,
|
||||
"sanity check: resetting the URL to about:newtab should return about:newtab");
|
||||
|
||||
// remove the tab and move on
|
||||
gBrowser.removeCurrentTab();
|
||||
TestRunner.next();
|
||||
}, true);
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
// test the default behavior
|
||||
yield addNewTabPageTab();
|
||||
browser = gWindow.gBrowser.selectedBrowser;
|
||||
|
||||
ok(!aboutNewTabService.overridden,
|
||||
"sanity check: default URL for about:newtab should not be overriden");
|
||||
browser.contentWindow.location = ABOUT_NEWTAB_URI;
|
||||
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
is(content.document.location, ABOUT_NEWTAB_URI, "document.location should match about:newtab");
|
||||
is(content.document.documentURI, ABOUT_NEWTAB_URI, "document.documentURI should match about:newtab");
|
||||
is(content.document.nodePrincipal,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
"nodePrincipal should match systemPrincipal");
|
||||
|
||||
// also test the pref
|
||||
testPref();
|
||||
}, true);
|
||||
|
||||
info("Waiting for about:newtab to load ...");
|
||||
yield true;
|
||||
}
|
||||
// remove the tab and move on
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче