fune/browser/base/content/test/tabs/browser_isLocalAboutURI.js
Jay Lim b232c83d80 Bug 1472212 - Ensure that tab does not show busy or burst status whenever we navigate to about:home, about:newtab, or about:welcome in a new window. r=Gijs
Now that we have moved some about: pages to the privileged content process,
opening these URLs from a non-privileged content process will trigger SessionStore
to restore the tab state due to a process flip. We will set favicons for these
URLs earlier to avoid flickering and improve perceived performance.

This patch also prevents the spinner whenever a page with a local about: URI
(about:blank and about: pages that resolve to jar:// or file:// URIs) is
loaded from a process that the URI cannot load in (e.g. loading about:newtab
in the web content process), as well as during tab duplication or session
restoration for such local about: URIs.

Before this patch, there were additional frames when opening a new window, causing
browser/base/content/test/performance/browser_windowopen.js to fail. This patch
will reduce the number of frames when opening a new window.

MozReview-Commit-ID: yjj2964KSz

--HG--
extra : source : cecc2d52e72e7c6e61137a9147735cb07a079d51
extra : intermediate-source : 21a6f1a83c73ce4fff654d4b2118e98375f0a528
extra : histedit_source : e8b8132856b7ee27b530798c2721b76118de655e
2018-07-20 16:43:12 -04:00

47 lines
1.7 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Unit tests for tabbrowser.isLocalAboutURI to make sure it returns the
* appropriate values for various URIs as well as optional resolved URI.
*/
add_task(function test_URI() {
const check = (spec, expect, description) => {
const URI = Services.io.newURI(spec);
try {
is(gBrowser.isLocalAboutURI(URI), expect, description);
} catch (ex) {
ok(false, "isLocalAboutURI should not throw");
}
};
check("https://www.mozilla.org/", false, "https is not about");
check("http://www.mozilla.org/", false, "http is not about");
check("about:blank", true, "about:blank is local");
check("about:about", true, "about:about is local");
check("about:newtab", true, "about:newtab is local");
check("about:random-invalid-uri", false,
"about:random-invalid-uri is invalid but should not throw");
});
add_task(function test_URI_with_resolved() {
const check = (spec, resolvedSpec, expect, description) => {
const URI = Services.io.newURI(spec);
const resolvedURI = Services.io.newURI(resolvedSpec);
is(gBrowser.isLocalAboutURI(URI, resolvedURI), expect, description);
};
check("about:newtab",
"jar:file:///Applications/Firefox.app/Contents/Resources/browser/omni.ja!/chrome/browser/res/activity-stream/prerendered/en-US/activity-stream.html",
true,
"about:newtab with jar is local");
check("about:newtab",
"file:///mozilla-central/browser/base/content/newtab/newTab.xhtml",
true,
"about:newtab with file is local");
check("about:newtab",
"https://www.mozilla.org/newtab",
false,
"about:newtab with https is not local");
});