diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp index be2b503f6414..239562d3e167 100644 --- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -22,6 +22,7 @@ namespace browser { NS_IMPL_ISUPPORTS(AboutRedirector, nsIAboutModule) bool AboutRedirector::sUseOldPreferences = false; +bool AboutRedirector::sActivityStreamEnabled = false; struct RedirEntry { const char* id; @@ -206,8 +207,26 @@ AboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result) nsAutoCString name = GetAboutModuleName(aURI); + static bool sASEnabledCacheInited = false; + if (!sASEnabledCacheInited) { + Preferences::AddBoolVarCache(&sActivityStreamEnabled, + "browser.newtabpage.activity-stream.enabled"); + sASEnabledCacheInited = true; + } + for (auto & redir : kRedirMap) { if (name.Equals(redir.id)) { + + // Once ActivityStream is fully rolled out and we've removed Tiles, + // this special case can go away and the flag can just become part + // of the normal about:newtab entry in kRedirMap. + if (name.EqualsLiteral("newtab")) { + if (sActivityStreamEnabled) { + *result = redir.flags | nsIAboutModule::URI_MUST_LOAD_IN_CHILD; + return NS_OK; + } + } + *result = redir.flags; return NS_OK; } diff --git a/browser/components/about/AboutRedirector.h b/browser/components/about/AboutRedirector.h index eaf25e3400a9..885302522db5 100644 --- a/browser/components/about/AboutRedirector.h +++ b/browser/components/about/AboutRedirector.h @@ -27,6 +27,7 @@ protected: private: static bool sUseOldPreferences; + static bool sActivityStreamEnabled; }; } // namespace browser diff --git a/browser/components/about/moz.build b/browser/components/about/moz.build index a1556825b1ab..4f14bc5a92a0 100644 --- a/browser/components/about/moz.build +++ b/browser/components/about/moz.build @@ -11,6 +11,8 @@ EXPORTS.mozilla.browser += [ 'AboutRedirector.h', ] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] + SOURCES += [ 'AboutRedirector.cpp', ] diff --git a/browser/components/about/test/unit/test_getURIFlags.js b/browser/components/about/test/unit/test_getURIFlags.js new file mode 100644 index 000000000000..c28fa09facfb --- /dev/null +++ b/browser/components/about/test/unit/test_getURIFlags.js @@ -0,0 +1,33 @@ +const {classes: Cc, interfaces: Ci, utils: Cu} = Components; + +Cu.import("resource://gre/modules/Services.jsm"); + +const contract = "@mozilla.org/network/protocol/about;1?what=newtab"; +const am = Cc[contract].getService(Ci.nsIAboutModule); +const uri = Services.io.newURI("about:newtab"); + +function run_test() { + test_AS_enabled_flags(); + test_AS_disabled_flags(); +} + +// Since tiles isn't e10s capable, it shouldn't advertise that it can load in +// the child. +function test_AS_disabled_flags() { + Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", + false); + + let flags = am.getURIFlags(uri); + + ok(!(flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD)); +} + +// Activity Stream, however, is e10s-capable, and should advertise it. +function test_AS_enabled_flags() { + Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", + true); + + let flags = am.getURIFlags(uri); + + ok(flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD); +} diff --git a/browser/components/about/test/unit/xpcshell.ini b/browser/components/about/test/unit/xpcshell.ini new file mode 100644 index 000000000000..4fcef61417bf --- /dev/null +++ b/browser/components/about/test/unit/xpcshell.ini @@ -0,0 +1,6 @@ +[DEFAULT] +head = +# make the firefox services (eg newtab-service) available to xpcshell +firefox-appdir = browser + +[test_getURIFlags.js] diff --git a/browser/components/sessionstore/test/browser_background_tab_crash.js b/browser/components/sessionstore/test/browser_background_tab_crash.js index f0dfa5ac0e15..bd66b94d265b 100644 --- a/browser/components/sessionstore/test/browser_background_tab_crash.js +++ b/browser/components/sessionstore/test/browser_background_tab_crash.js @@ -242,12 +242,7 @@ add_task(async function test_preload_crash() { // Create a fresh preloaded browser gBrowser._createPreloadBrowser(); - // XXX Temporarily disabled until bug 1365643 relands. At that time, this - // this statement, as well as the eslint-disable-line below, should be - // removed. - return; - - await BrowserTestUtils.crashBrowser(gBrowser._preloadedBrowser, false); // eslint-disable-line no-unreachable + await BrowserTestUtils.crashBrowser(gBrowser._preloadedBrowser, false); Assert.ok(!gBrowser._preloadedBrowser); });