diff --git a/.eslintrc.js b/.eslintrc.js
index b7f5ec97474c..3b759c24d2be 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -45,7 +45,6 @@ module.exports = {
"overrides": [{
"files": [
"devtools/**",
- "docshell/**",
"dom/**",
"editor/**",
"extensions/**",
diff --git a/.prettierignore b/.prettierignore
index c8815b91235a..e9888262ddde 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js
toolkit/components/telemetry/healthreport-prefs.js
# Ignore all top-level directories for now.
-docshell/**
dom/**
editor/**
extensions/**
diff --git a/docshell/resources/content/netError.js b/docshell/resources/content/netError.js
index a86725c381e8..4caf4c64e975 100644
--- a/docshell/resources/content/netError.js
+++ b/docshell/resources/content/netError.js
@@ -1,267 +1,282 @@
- // Error url MUST be formatted like this:
- // moz-neterror:page?e=error&u=url&d=desc
- //
- // or optionally, to specify an alternate CSS class to allow for
- // custom styling and favicon:
- //
- // moz-neterror:page?e=error&u=url&s=classname&d=desc
+// Error url MUST be formatted like this:
+// moz-neterror:page?e=error&u=url&d=desc
+//
+// or optionally, to specify an alternate CSS class to allow for
+// custom styling and favicon:
+//
+// moz-neterror:page?e=error&u=url&s=classname&d=desc
- // Note that this file uses document.documentURI to get
- // the URL (with the format from above). This is because
- // document.location.href gets the current URI off the docshell,
- // which is the URL displayed in the location bar, i.e.
- // the URI that the user attempted to load.
+// Note that this file uses document.documentURI to get
+// the URL (with the format from above). This is because
+// document.location.href gets the current URI off the docshell,
+// which is the URL displayed in the location bar, i.e.
+// the URI that the user attempted to load.
- function getErrorCode() {
- var url = document.documentURI;
- var error = url.search(/e\=/);
- var duffUrl = url.search(/\&u\=/);
- return decodeURIComponent(url.slice(error + 2, duffUrl));
- }
+function getErrorCode() {
+ var url = document.documentURI;
+ var error = url.search(/e\=/);
+ var duffUrl = url.search(/\&u\=/);
+ return decodeURIComponent(url.slice(error + 2, duffUrl));
+}
- function getCSSClass() {
- var url = document.documentURI;
- var matches = url.match(/s\=([^&]+)\&/);
- // s is optional, if no match just return nothing
- if (!matches || matches.length < 2)
- return "";
+function getCSSClass() {
+ var url = document.documentURI;
+ var matches = url.match(/s\=([^&]+)\&/);
+ // s is optional, if no match just return nothing
+ if (!matches || matches.length < 2) {
+ return "";
+ }
- // parenthetical match is the second entry
- return decodeURIComponent(matches[1]);
- }
+ // parenthetical match is the second entry
+ return decodeURIComponent(matches[1]);
+}
- function getDescription() {
- var url = document.documentURI;
- var desc = url.search(/d\=/);
+function getDescription() {
+ var url = document.documentURI;
+ var desc = url.search(/d\=/);
- // desc == -1 if not found; if so, return an empty string
- // instead of what would turn out to be portions of the URI
- if (desc == -1)
- return "";
+ // desc == -1 if not found; if so, return an empty string
+ // instead of what would turn out to be portions of the URI
+ if (desc == -1) {
+ return "";
+ }
- return decodeURIComponent(url.slice(desc + 2));
- }
+ return decodeURIComponent(url.slice(desc + 2));
+}
- function retryThis(buttonEl) {
- // Note: The application may wish to handle switching off "offline mode"
- // before this event handler runs, but using a capturing event handler.
+function retryThis(buttonEl) {
+ // Note: The application may wish to handle switching off "offline mode"
+ // before this event handler runs, but using a capturing event handler.
- // Session history has the URL of the page that failed
- // to load, not the one of the error page. So, just call
- // reload(), which will also repost POST data correctly.
- try {
- location.reload();
- } catch (e) {
- // We probably tried to reload a URI that caused an exception to
- // occur; e.g. a nonexistent file.
- }
+ // Session history has the URL of the page that failed
+ // to load, not the one of the error page. So, just call
+ // reload(), which will also repost POST data correctly.
+ try {
+ location.reload();
+ } catch (e) {
+ // We probably tried to reload a URI that caused an exception to
+ // occur; e.g. a nonexistent file.
+ }
- buttonEl.disabled = true;
- }
+ buttonEl.disabled = true;
+}
- function initPage() {
- var err = getErrorCode();
+function initPage() {
+ var err = getErrorCode();
- // if it's an unknown error or there's no title or description
- // defined, get the generic message
- var errTitle = document.getElementById("et_" + err);
- var errDesc = document.getElementById("ed_" + err);
- if (!errTitle || !errDesc) {
- errTitle = document.getElementById("et_generic");
- errDesc = document.getElementById("ed_generic");
- }
+ // if it's an unknown error or there's no title or description
+ // defined, get the generic message
+ var errTitle = document.getElementById("et_" + err);
+ var errDesc = document.getElementById("ed_" + err);
+ if (!errTitle || !errDesc) {
+ errTitle = document.getElementById("et_generic");
+ errDesc = document.getElementById("ed_generic");
+ }
- var title = document.getElementById("errorTitleText");
- if (title) {
- title.parentNode.replaceChild(errTitle, title);
- // change id to the replaced child's id so styling works
- errTitle.id = "errorTitleText";
- }
+ var title = document.getElementById("errorTitleText");
+ if (title) {
+ title.parentNode.replaceChild(errTitle, title);
+ // change id to the replaced child's id so styling works
+ errTitle.id = "errorTitleText";
+ }
- var sd = document.getElementById("errorShortDescText");
- if (sd)
- sd.textContent = getDescription();
+ var sd = document.getElementById("errorShortDescText");
+ if (sd) {
+ sd.textContent = getDescription();
+ }
- var ld = document.getElementById("errorLongDesc");
- if (ld) {
- ld.parentNode.replaceChild(errDesc, ld);
- // change id to the replaced child's id so styling works
- errDesc.id = "errorLongDesc";
- }
+ var ld = document.getElementById("errorLongDesc");
+ if (ld) {
+ ld.parentNode.replaceChild(errDesc, ld);
+ // change id to the replaced child's id so styling works
+ errDesc.id = "errorLongDesc";
+ }
- // remove undisplayed errors to avoid bug 39098
- var errContainer = document.getElementById("errorContainer");
- errContainer.remove();
+ // remove undisplayed errors to avoid bug 39098
+ var errContainer = document.getElementById("errorContainer");
+ errContainer.remove();
- var className = getCSSClass();
- if (className && className != "expertBadCert") {
- // Associate a CSS class with the root of the page, if one was passed in,
- // to allow custom styling.
- // Not "expertBadCert" though, don't want to deal with the favicon
- document.documentElement.className = className;
+ var className = getCSSClass();
+ if (className && className != "expertBadCert") {
+ // Associate a CSS class with the root of the page, if one was passed in,
+ // to allow custom styling.
+ // Not "expertBadCert" though, don't want to deal with the favicon
+ document.documentElement.className = className;
- // Also, if they specified a CSS class, they must supply their own
- // favicon. In order to trigger the browser to repaint though, we
- // need to remove/add the link element.
- var favicon = document.getElementById("favicon");
- var faviconParent = favicon.parentNode;
- faviconParent.removeChild(favicon);
- favicon.setAttribute("href", "chrome://global/skin/icons/" + className + "_favicon.png");
- faviconParent.appendChild(favicon);
- }
- if (className == "expertBadCert") {
- showSecuritySection();
- }
+ // Also, if they specified a CSS class, they must supply their own
+ // favicon. In order to trigger the browser to repaint though, we
+ // need to remove/add the link element.
+ var favicon = document.getElementById("favicon");
+ var faviconParent = favicon.parentNode;
+ faviconParent.removeChild(favicon);
+ favicon.setAttribute(
+ "href",
+ "chrome://global/skin/icons/" + className + "_favicon.png"
+ );
+ faviconParent.appendChild(favicon);
+ }
+ if (className == "expertBadCert") {
+ showSecuritySection();
+ }
- if (err == "remoteXUL") {
- // Remove the "Try again" button for remote XUL errors given that
- // it is useless.
- document.getElementById("errorTryAgain").style.display = "none";
- }
+ if (err == "remoteXUL") {
+ // Remove the "Try again" button for remote XUL errors given that
+ // it is useless.
+ document.getElementById("errorTryAgain").style.display = "none";
+ }
- if (err == "cspBlocked") {
- // Remove the "Try again" button for CSP violations, since it's
- // almost certainly useless. (Bug 553180)
- document.getElementById("errorTryAgain").style.display = "none";
- }
+ if (err == "cspBlocked") {
+ // Remove the "Try again" button for CSP violations, since it's
+ // almost certainly useless. (Bug 553180)
+ document.getElementById("errorTryAgain").style.display = "none";
+ }
- if (err == "nssBadCert") {
- // Remove the "Try again" button for security exceptions, since it's
- // almost certainly useless.
- document.getElementById("errorTryAgain").style.display = "none";
- document.getElementById("errorPageContainer").setAttribute("class", "certerror");
- addDomainErrorLink();
- } else {
- // Remove the override block for non-certificate errors. CSS-hiding
- // isn't good enough here, because of bug 39098
- var secOverride = document.getElementById("securityOverrideDiv");
- secOverride.remove();
- }
+ if (err == "nssBadCert") {
+ // Remove the "Try again" button for security exceptions, since it's
+ // almost certainly useless.
+ document.getElementById("errorTryAgain").style.display = "none";
+ document
+ .getElementById("errorPageContainer")
+ .setAttribute("class", "certerror");
+ addDomainErrorLink();
+ } else {
+ // Remove the override block for non-certificate errors. CSS-hiding
+ // isn't good enough here, because of bug 39098
+ var secOverride = document.getElementById("securityOverrideDiv");
+ secOverride.remove();
+ }
- if (err == "inadequateSecurityError" || err == "blockedByPolicy") {
- // Remove the "Try again" button from pages that don't need it.
- // For HTTP/2 inadequate security or pages blocked by policy, trying
- // again won't help.
- document.getElementById("errorTryAgain").style.display = "none";
+ if (err == "inadequateSecurityError" || err == "blockedByPolicy") {
+ // Remove the "Try again" button from pages that don't need it.
+ // For HTTP/2 inadequate security or pages blocked by policy, trying
+ // again won't help.
+ document.getElementById("errorTryAgain").style.display = "none";
- var container = document.getElementById("errorLongDesc");
- for (var span of container.querySelectorAll("span.hostname")) {
- span.textContent = document.location.hostname;
- }
- }
+ var container = document.getElementById("errorLongDesc");
+ for (var span of container.querySelectorAll("span.hostname")) {
+ span.textContent = document.location.hostname;
+ }
+ }
- if (document.getElementById("errorTryAgain").style.display != "none")
- addAutofocus("errorTryAgain");
- }
+ if (document.getElementById("errorTryAgain").style.display != "none") {
+ addAutofocus("errorTryAgain");
+ }
+}
- function showSecuritySection() {
- // Swap link out, content in
- document.getElementById("securityOverrideContent").style.display = "";
- document.getElementById("securityOverrideLink").style.display = "none";
- }
+function showSecuritySection() {
+ // Swap link out, content in
+ document.getElementById("securityOverrideContent").style.display = "";
+ document.getElementById("securityOverrideLink").style.display = "none";
+}
- /* In the case of SSL error pages about domain mismatch, see if
+/* In the case of SSL error pages about domain mismatch, see if
we can hyperlink the user to the correct site. We don't want
to do this generically since it allows MitM attacks to redirect
users to a site under attacker control, but in certain cases
it is safe (and helpful!) to do so. Bug 402210
*/
- function addDomainErrorLink() {
- // Rather than textContent, we need to treat description as HTML
- var sd = document.getElementById("errorShortDescText");
- if (sd) {
- var desc = getDescription();
+function addDomainErrorLink() {
+ // Rather than textContent, we need to treat description as HTML
+ var sd = document.getElementById("errorShortDescText");
+ if (sd) {
+ var desc = getDescription();
- // sanitize description text - see bug 441169
+ // sanitize description text - see bug 441169
- // First, find the index of the tag we care about, being careful not to
- // use an over-greedy regex
- var re = //;
- var result = re.exec(desc);
- if (!result)
- return;
+ // First, find the index of the tag we care about, being careful not to
+ // use an over-greedy regex
+ var re = //;
+ var result = re.exec(desc);
+ if (!result) {
+ return;
+ }
- // Remove sd's existing children
- sd.textContent = "";
+ // Remove sd's existing children
+ sd.textContent = "";
- // Everything up to the link should be text content
- sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
+ // Everything up to the link should be text content
+ sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
- // Now create the link itself
- var anchorEl = document.createElement("a");
- anchorEl.setAttribute("id", "cert_domain_link");
- anchorEl.setAttribute("title", result[1]);
- anchorEl.appendChild(document.createTextNode(result[1]));
- sd.appendChild(anchorEl);
+ // Now create the link itself
+ var anchorEl = document.createElement("a");
+ anchorEl.setAttribute("id", "cert_domain_link");
+ anchorEl.setAttribute("title", result[1]);
+ anchorEl.appendChild(document.createTextNode(result[1]));
+ sd.appendChild(anchorEl);
- // Finally, append text for anything after the closing
- sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("") + "".length)));
- }
+ // Finally, append text for anything after the closing
+ sd.appendChild(
+ document.createTextNode(desc.slice(desc.indexOf("") + "".length))
+ );
+ }
- var link = document.getElementById("cert_domain_link");
- if (!link)
- return;
+ var link = document.getElementById("cert_domain_link");
+ if (!link) {
+ return;
+ }
- var okHost = link.getAttribute("title");
- var thisHost = document.location.hostname;
- var proto = document.location.protocol;
+ var okHost = link.getAttribute("title");
+ var thisHost = document.location.hostname;
+ var proto = document.location.protocol;
- // If okHost is a wildcard domain ("*.example.com") let's
- // use "www" instead. "*.example.com" isn't going to
- // get anyone anywhere useful. bug 432491
- okHost = okHost.replace(/^\*\./, "www.");
+ // If okHost is a wildcard domain ("*.example.com") let's
+ // use "www" instead. "*.example.com" isn't going to
+ // get anyone anywhere useful. bug 432491
+ okHost = okHost.replace(/^\*\./, "www.");
- /* case #1:
- * example.com uses an invalid security certificate.
- *
- * The certificate is only valid for www.example.com
- *
- * Make sure to include the "." ahead of thisHost so that
- * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
- *
- * We'd normally just use a RegExp here except that we lack a
- * library function to escape them properly (bug 248062), and
- * domain names are famous for having '.' characters in them,
- * which would allow spurious and possibly hostile matches.
- */
- if (endsWith(okHost, "." + thisHost))
- link.href = proto + okHost;
+ /* case #1:
+ * example.com uses an invalid security certificate.
+ *
+ * The certificate is only valid for www.example.com
+ *
+ * Make sure to include the "." ahead of thisHost so that
+ * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
+ *
+ * We'd normally just use a RegExp here except that we lack a
+ * library function to escape them properly (bug 248062), and
+ * domain names are famous for having '.' characters in them,
+ * which would allow spurious and possibly hostile matches.
+ */
+ if (endsWith(okHost, "." + thisHost)) {
+ link.href = proto + okHost;
+ }
- /* case #2:
- * browser.garage.maemo.org uses an invalid security certificate.
- *
- * The certificate is only valid for garage.maemo.org
- */
- if (endsWith(thisHost, "." + okHost))
- link.href = proto + okHost;
- }
+ /* case #2:
+ * browser.garage.maemo.org uses an invalid security certificate.
+ *
+ * The certificate is only valid for garage.maemo.org
+ */
+ if (endsWith(thisHost, "." + okHost)) {
+ link.href = proto + okHost;
+ }
+}
- function endsWith(haystack, needle) {
- return haystack.slice(-needle.length) == needle;
- }
+function endsWith(haystack, needle) {
+ return haystack.slice(-needle.length) == needle;
+}
- /* Only do autofocus if we're the toplevel frame; otherwise we
+/* Only do autofocus if we're the toplevel frame; otherwise we
don't want to call attention to ourselves! The key part is
that autofocus happens on insertion into the tree, so we
can remove the button, add @autofocus, and reinsert the
button.
*/
- function addAutofocus(buttonId, position = "afterbegin") {
- if (window.top == window) {
- var button = document.getElementById(buttonId);
- var parent = button.parentNode;
- button.remove();
- button.setAttribute("autofocus", "true");
- parent.insertAdjacentElement(position, button);
- }
- }
+function addAutofocus(buttonId, position = "afterbegin") {
+ if (window.top == window) {
+ var button = document.getElementById(buttonId);
+ var parent = button.parentNode;
+ button.remove();
+ button.setAttribute("autofocus", "true");
+ parent.insertAdjacentElement(position, button);
+ }
+}
- let errorTryAgain = document.getElementById("errorTryAgain");
- errorTryAgain.addEventListener("click", function() {
- retryThis(this);
- });
+let errorTryAgain = document.getElementById("errorTryAgain");
+errorTryAgain.addEventListener("click", function() {
+ retryThis(this);
+});
- // Note: It is important to run the script this way, instead of using
- // an onload handler. This is because error pages are loaded as
- // LOAD_BACKGROUND, which means that onload handlers will not be executed.
- initPage();
+// Note: It is important to run the script this way, instead of using
+// an onload handler. This is because error pages are loaded as
+// LOAD_BACKGROUND, which means that onload handlers will not be executed.
+initPage();
diff --git a/docshell/test/browser/browser_browsingContext-01.js b/docshell/test/browser/browser_browsingContext-01.js
index 0749d0d154bd..c66c099123e1 100644
--- a/docshell/test/browser/browser_browsingContext-01.js
+++ b/docshell/test/browser/browser_browsingContext-01.js
@@ -6,75 +6,69 @@
const URL = "about:blank";
async function getBrowsingContextId(browser, id) {
- return ContentTask.spawn(
- browser,
- id,
- async function(id) {
- let contextId = content.window.docShell.browsingContext.id;
+ return ContentTask.spawn(browser, id, async function(id) {
+ let contextId = content.window.docShell.browsingContext.id;
- let frames = [content.window];
- while (frames.length) {
- let frame = frames.pop();
- let target = frame.document.getElementById(id);
- if (target) {
- contextId = target.docShell.browsingContext.id;
- break;
- }
-
- frames = frames.concat(Array.from(frame.frames));
+ let frames = [content.window];
+ while (frames.length) {
+ let frame = frames.pop();
+ let target = frame.document.getElementById(id);
+ if (target) {
+ contextId = target.docShell.browsingContext.id;
+ break;
}
- return contextId;
- });
+ frames = frames.concat(Array.from(frame.frames));
+ }
+
+ return contextId;
+ });
}
async function addFrame(browser, id, parentId) {
- return ContentTask.spawn(
- browser,
- {parentId, id},
- async function({ parentId, id }) {
- let parent = null;
- if (parentId) {
- let frames = [content.window];
- while (frames.length) {
- let frame = frames.pop();
- let target = frame.document.getElementById(parentId);
- if (target) {
- parent = target.contentWindow.document.body;
- break;
- }
- frames = frames.concat(Array.from(frame.frames));
- }
- } else {
- parent = content.document.body;
- }
-
- let frame = content.document.createElement("iframe");
- frame.id = id || "";
- frame.url = "about:blank";
- parent.appendChild(frame);
-
- return frame.contentWindow.docShell.browsingContext.id;
- });
-}
-
-async function removeFrame(browser, id) {
- return ContentTask.spawn(
- browser,
+ return ContentTask.spawn(browser, { parentId, id }, async function({
+ parentId,
id,
- async function(id) {
+ }) {
+ let parent = null;
+ if (parentId) {
let frames = [content.window];
while (frames.length) {
let frame = frames.pop();
- let target = frame.document.getElementById(id);
+ let target = frame.document.getElementById(parentId);
if (target) {
- target.remove();
+ parent = target.contentWindow.document.body;
break;
}
-
frames = frames.concat(Array.from(frame.frames));
}
- });
+ } else {
+ parent = content.document.body;
+ }
+
+ let frame = content.document.createElement("iframe");
+ frame.id = id || "";
+ frame.url = "about:blank";
+ parent.appendChild(frame);
+
+ return frame.contentWindow.docShell.browsingContext.id;
+ });
+}
+
+async function removeFrame(browser, id) {
+ return ContentTask.spawn(browser, id, async function(id) {
+ let frames = [content.window];
+ while (frames.length) {
+ let frame = frames.pop();
+ let target = frame.document.getElementById(id);
+ if (target) {
+ target.remove();
+ break;
+ }
+
+ frames = frames.concat(Array.from(frame.frames));
+ }
+ });
}
function getBrowsingContextById(id) {
@@ -82,57 +76,76 @@ function getBrowsingContextById(id) {
}
add_task(async function() {
- await BrowserTestUtils.withNewTab({ gBrowser, url: URL },
- async function(browser) {
- let topId = await getBrowsingContextId(browser, "");
- let topContext = getBrowsingContextById(topId);
- isnot(topContext, null);
- is(topContext.parent, null);
- is(topId, browser.browsingContext.id, " has the correct browsingContext");
+ await BrowserTestUtils.withNewTab({ gBrowser, url: URL }, async function(
+ browser
+ ) {
+ let topId = await getBrowsingContextId(browser, "");
+ let topContext = getBrowsingContextById(topId);
+ isnot(topContext, null);
+ is(topContext.parent, null);
+ is(
+ topId,
+ browser.browsingContext.id,
+ " has the correct browsingContext"
+ );
- let id0 = await addFrame(browser, "frame0");
- let browsingContext0 = getBrowsingContextById(id0);
- isnot(browsingContext0, null);
- is(browsingContext0.parent, topContext);
+ let id0 = await addFrame(browser, "frame0");
+ let browsingContext0 = getBrowsingContextById(id0);
+ isnot(browsingContext0, null);
+ is(browsingContext0.parent, topContext);
- let id1 = await addFrame(browser, "frame1", "frame0");
- let browsingContext1 = getBrowsingContextById(id1);
- isnot(browsingContext1, null);
- is(browsingContext1.parent, browsingContext0);
+ let id1 = await addFrame(browser, "frame1", "frame0");
+ let browsingContext1 = getBrowsingContextById(id1);
+ isnot(browsingContext1, null);
+ is(browsingContext1.parent, browsingContext0);
- let id2 = await addFrame(browser, "frame2", "frame1");
- let browsingContext2 = getBrowsingContextById(id2);
- isnot(browsingContext2, null);
- is(browsingContext2.parent, browsingContext1);
+ let id2 = await addFrame(browser, "frame2", "frame1");
+ let browsingContext2 = getBrowsingContextById(id2);
+ isnot(browsingContext2, null);
+ is(browsingContext2.parent, browsingContext1);
- await removeFrame(browser, "frame2");
+ await removeFrame(browser, "frame2");
- is(browsingContext1.getChildren().indexOf(browsingContext2), -1);
+ is(browsingContext1.getChildren().indexOf(browsingContext2), -1);
- // TODO(farre): Handle browsingContext removal [see Bug 1486719].
- todo_isnot(browsingContext2.parent, browsingContext1);
+ // TODO(farre): Handle browsingContext removal [see Bug 1486719].
+ todo_isnot(browsingContext2.parent, browsingContext1);
});
});
add_task(async function() {
- await BrowserTestUtils.withNewTab({ gBrowser, url: getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.com") + "dummy_page.html" },
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url:
+ getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "http://example.com"
+ ) + "dummy_page.html",
+ },
async function(browser) {
- let path = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.com");
+ let path = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "http://example.com"
+ );
await ContentTask.spawn(browser, path, async function(path) {
function waitForMessage(command) {
let r;
let p = new Promise(resolve => {
- content.window.addEventListener("message", e => resolve({result: r, event: e}),
- {once: true});
+ content.window.addEventListener(
+ "message",
+ e => resolve({ result: r, event: e }),
+ { once: true }
+ );
});
r = command();
return p;
}
// Open a new window and wait for the message.
- let { result: win, event: e1 } =
- await waitForMessage(
- _ => content.window.open(path + "onpageshow_message.html"));
+ let { result: win, event: e1 } = await waitForMessage(_ =>
+ content.window.open(path + "onpageshow_message.html")
+ );
is(e1.data, "pageshow");
@@ -152,7 +165,8 @@ add_task(async function() {
// Navigate the window and wait for the message.
let { event: e2 } = await waitForMessage(
- _ => win.location = path + "onload_message.html");
+ _ => (win.location = path + "onload_message.html")
+ );
is(e2.data, "load");
is(win.frames.length, 0, "Here there shouldn't be an iframe");
@@ -165,15 +179,29 @@ add_task(async function() {
is(win.frames.length, 1, "And again there should be an iframe");
is(winDocShell, win.frames[0].docShell, "BF cache cached docshell");
- is(frameBC, win.frames[0].docShell.browsingContext, "BF cache cached BC");
- is(frameBC.id, win.frames[0].docShell.browsingContext.id,
- "BF cached BC's have same id");
- is(win.docShell.browsingContext.getChildren()[0], frameBC,
- "BF cached BC's should still be a child of its parent");
- is(win.docShell.browsingContext, frameBC.parent,
- "BF cached BC's should still be a connected to its parent");
+ is(
+ frameBC,
+ win.frames[0].docShell.browsingContext,
+ "BF cache cached BC"
+ );
+ is(
+ frameBC.id,
+ win.frames[0].docShell.browsingContext.id,
+ "BF cached BC's have same id"
+ );
+ is(
+ win.docShell.browsingContext.getChildren()[0],
+ frameBC,
+ "BF cached BC's should still be a child of its parent"
+ );
+ is(
+ win.docShell.browsingContext,
+ frameBC.parent,
+ "BF cached BC's should still be a connected to its parent"
+ );
win.close();
});
- });
+ }
+ );
});
diff --git a/docshell/test/browser/browser_browsingContext-02.js b/docshell/test/browser/browser_browsingContext-02.js
index 8b07227fc641..932d369862c7 100644
--- a/docshell/test/browser/browser_browsingContext-02.js
+++ b/docshell/test/browser/browser_browsingContext-02.js
@@ -5,114 +5,144 @@
add_task(async function() {
await BrowserTestUtils.withNewTab(
- {gBrowser, url: "about:blank"}, async function(browser) {
- const BASE1 = getRootDirectory(gTestPath)
- .replace("chrome://mochitests/content", "http://example.com");
- const BASE2 = getRootDirectory(gTestPath)
- .replace("chrome://mochitests/content", "http://test1.example.com");
+ { gBrowser, url: "about:blank" },
+ async function(browser) {
+ const BASE1 = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "http://example.com"
+ );
+ const BASE2 = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "http://test1.example.com"
+ );
const URL = BASE1 + "onload_message.html";
- let sixth = BrowserTestUtils.waitForNewTab(gBrowser, URL + "#sixth", true, true);
- let seventh = BrowserTestUtils.waitForNewTab(gBrowser, URL + "#seventh", true, true);
- await ContentTask.spawn(browser, {base1: BASE1, base2: BASE2},
- async function({base1, base2}) {
- let top = content.window;
- top.name = "top";
- top.location.href += "#top";
+ let sixth = BrowserTestUtils.waitForNewTab(
+ gBrowser,
+ URL + "#sixth",
+ true,
+ true
+ );
+ let seventh = BrowserTestUtils.waitForNewTab(
+ gBrowser,
+ URL + "#seventh",
+ true,
+ true
+ );
+ await ContentTask.spawn(
+ browser,
+ { base1: BASE1, base2: BASE2 },
+ async function({ base1, base2 }) {
+ let top = content.window;
+ top.name = "top";
+ top.location.href += "#top";
- let contexts = {
- top: top.location.href,
- first: base1 + "dummy_page.html#first",
- third: base2 + "dummy_page.html#third",
- second: base1 + "dummy_page.html#second",
- fourth: base2 + "dummy_page.html#fourth",
- fifth: base1 + "dummy_page.html#fifth",
- sixth: base1 + "onload_message.html#sixth",
- seventh: base1 + "onload_message.html#seventh",
- };
+ let contexts = {
+ top: top.location.href,
+ first: base1 + "dummy_page.html#first",
+ third: base2 + "dummy_page.html#third",
+ second: base1 + "dummy_page.html#second",
+ fourth: base2 + "dummy_page.html#fourth",
+ fifth: base1 + "dummy_page.html#fifth",
+ sixth: base1 + "onload_message.html#sixth",
+ seventh: base1 + "onload_message.html#seventh",
+ };
- function addFrame(target, name) {
- let doc = (target.contentWindow || target).document;
- let frame = doc.createElement("iframe");
- let p = new Promise(resolve => (frame.onload = () => resolve(frame)));
- doc.body.appendChild(frame);
- frame.name = name;
- frame.src = contexts[name];
- return p;
- }
-
- function addWindow(target, name, {options, resolve}) {
- var win = target.contentWindow.open(contexts[name], name, options);
-
- if (resolve) {
- return new Promise(
- resolve => target.contentWindow.addEventListener(
- "message", () => resolve(win)));
+ function addFrame(target, name) {
+ let doc = (target.contentWindow || target).document;
+ let frame = doc.createElement("iframe");
+ let p = new Promise(
+ resolve => (frame.onload = () => resolve(frame))
+ );
+ doc.body.appendChild(frame);
+ frame.name = name;
+ frame.src = contexts[name];
+ return p;
}
- return Promise.resolve({name});
- }
- // We're going to create a tree that looks like the
- // following.
- //
- // top sixth seventh
- // / \
- // / \ /
- // first second
- // / \ /
- // / \
- // third fourth - - -
- // /
- // /
- // fifth
- //
- // The idea is to have one top level non-auxiliary browsing
- // context, five nested, one top level auxiliary with an
- // opener, and one top level without an opener. Given that
- // set of related and one unrelated browsing contexts we
- // wish to confirm that targeting is able to find
- // appropriate browsing contexts.
+ function addWindow(target, name, { options, resolve }) {
+ var win = target.contentWindow.open(contexts[name], name, options);
+ if (resolve) {
+ return new Promise(resolve =>
+ target.contentWindow.addEventListener("message", () =>
+ resolve(win)
+ )
+ );
+ }
+ return Promise.resolve({ name });
+ }
- function bc(frame) {
- return (frame.contentWindow || frame).docShell.browsingContext;
- }
+ // We're going to create a tree that looks like the
+ // following.
+ //
+ // top sixth seventh
+ // / \
+ // / \ /
+ // first second
+ // / \ /
+ // / \
+ // third fourth - - -
+ // /
+ // /
+ // fifth
+ //
+ // The idea is to have one top level non-auxiliary browsing
+ // context, five nested, one top level auxiliary with an
+ // opener, and one top level without an opener. Given that
+ // set of related and one unrelated browsing contexts we
+ // wish to confirm that targeting is able to find
+ // appropriate browsing contexts.
- function reachable(start, targets) {
- for (let target of targets) {
- is(bc(start).findWithName(target.name), bc(target),
- [bc(start).name, "can reach", target.name].join(" "));
+ function bc(frame) {
+ return (frame.contentWindow || frame).docShell.browsingContext;
+ }
+
+ function reachable(start, targets) {
+ for (let target of targets) {
+ is(
+ bc(start).findWithName(target.name),
+ bc(target),
+ [bc(start).name, "can reach", target.name].join(" ")
+ );
+ }
+ }
+
+ function unreachable(start, target) {
+ is(
+ bc(start).findWithName(target.name),
+ null,
+ [bc(start).name, "can't reach", target.name].join(" ")
+ );
+ }
+
+ let first = await addFrame(top, "first");
+ info("first");
+ let second = await addFrame(top, "second");
+ info("second");
+ let third = await addFrame(first, "third");
+ info("third");
+ let fourth = await addFrame(first, "fourth");
+ info("fourth");
+ let fifth = await addFrame(fourth, "fifth");
+ info("fifth");
+ let sixth = await addWindow(fourth, "sixth", { resolve: true });
+ info("sixth");
+ let seventh = await addWindow(fourth, "seventh", {
+ options: ["noopener"],
+ });
+ info("seventh");
+
+ let frames = [top, first, second, third, fourth, fifth, sixth];
+ for (let start of frames) {
+ reachable(start, frames);
+ unreachable(start, seventh);
}
}
-
- function unreachable(start, target) {
- is(bc(start).findWithName(target.name), null,
- [bc(start).name, "can't reach", target.name].join(" "));
- }
-
- let first = await addFrame(top, "first");
- info("first");
- let second = await addFrame(top, "second");
- info("second");
- let third = await addFrame(first, "third");
- info("third");
- let fourth = await addFrame(first, "fourth");
- info("fourth");
- let fifth = await addFrame(fourth, "fifth");
- info("fifth");
- let sixth = await addWindow(fourth, "sixth", { resolve: true });
- info("sixth");
- let seventh = await addWindow(fourth, "seventh", { options: ["noopener"] });
- info("seventh");
-
- let frames = [top, first, second, third, fourth, fifth, sixth];
- for (let start of frames) {
- reachable(start, frames);
- unreachable(start, seventh);
- }
- });
+ );
for (let tab of await Promise.all([sixth, seventh])) {
BrowserTestUtils.removeTab(tab);
}
- });
+ }
+ );
});
diff --git a/docshell/test/browser/browser_browsingContext-03.js b/docshell/test/browser/browser_browsingContext-03.js
index d5ef77f4b0ef..0f27883ca29e 100644
--- a/docshell/test/browser/browser_browsingContext-03.js
+++ b/docshell/test/browser/browser_browsingContext-03.js
@@ -5,132 +5,169 @@
add_task(async function() {
await BrowserTestUtils.withNewTab(
- {gBrowser, url: "about:blank"}, async function(browser) {
- const BASE1 = getRootDirectory(gTestPath)
- .replace("chrome://mochitests/content", "http://example.com");
- const BASE2 = getRootDirectory(gTestPath)
- .replace("chrome://mochitests/content", "http://test1.example.com");
+ { gBrowser, url: "about:blank" },
+ async function(browser) {
+ const BASE1 = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "http://example.com"
+ );
+ const BASE2 = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "http://test1.example.com"
+ );
const URL = BASE1 + "onload_message.html";
- let sixth = BrowserTestUtils.waitForNewTab(gBrowser, URL + "#sixth", true, true);
- await ContentTask.spawn(browser, {base1: BASE1, base2: BASE2},
- async function({base1, base2}) {
- let top = content.window;
- top.name = "top";
- top.location.href += "#top";
+ let sixth = BrowserTestUtils.waitForNewTab(
+ gBrowser,
+ URL + "#sixth",
+ true,
+ true
+ );
+ await ContentTask.spawn(
+ browser,
+ { base1: BASE1, base2: BASE2 },
+ async function({ base1, base2 }) {
+ let top = content.window;
+ top.name = "top";
+ top.location.href += "#top";
- let contexts = {
- top: top.location.href,
- first: base1 + "dummy_page.html#first",
- third: base2 + "dummy_page.html#third",
- second: base1 + "dummy_page.html#second",
- fourth: base2 + "dummy_page.html#fourth",
- fifth: base1 + "dummy_page.html#fifth",
- sixth: base1 + "onload_message.html#sixth",
- };
+ let contexts = {
+ top: top.location.href,
+ first: base1 + "dummy_page.html#first",
+ third: base2 + "dummy_page.html#third",
+ second: base1 + "dummy_page.html#second",
+ fourth: base2 + "dummy_page.html#fourth",
+ fifth: base1 + "dummy_page.html#fifth",
+ sixth: base1 + "onload_message.html#sixth",
+ };
- function addFrame(target, name) {
- let doc = (target.contentWindow || target).document;
- let frame = doc.createElement("iframe");
- let p = new Promise(resolve => (frame.onload = () => resolve(frame)));
- doc.body.appendChild(frame);
- frame.name = name;
- frame.src = contexts[name];
- return p;
- }
+ function addFrame(target, name) {
+ let doc = (target.contentWindow || target).document;
+ let frame = doc.createElement("iframe");
+ let p = new Promise(
+ resolve => (frame.onload = () => resolve(frame))
+ );
+ doc.body.appendChild(frame);
+ frame.name = name;
+ frame.src = contexts[name];
+ return p;
+ }
- function addWindow(target, name) {
- var win = target.contentWindow.open(contexts[name], name);
+ function addWindow(target, name) {
+ var win = target.contentWindow.open(contexts[name], name);
- return new Promise(
- resolve => target.contentWindow.addEventListener(
- "message", () => resolve(win)));
- }
+ return new Promise(resolve =>
+ target.contentWindow.addEventListener("message", () =>
+ resolve(win)
+ )
+ );
+ }
- // Generate all lists of length length with every combination of
- // values in input
- function* generate(input, length) {
- let list = new Array(length);
+ // Generate all lists of length length with every combination of
+ // values in input
+ function* generate(input, length) {
+ let list = new Array(length);
- function* values(pos) {
- if (pos >= list.length) {
- yield list;
- } else {
- for (let v of input) {
- list[pos] = v;
- yield* values(pos + 1);
+ function* values(pos) {
+ if (pos >= list.length) {
+ yield list;
+ } else {
+ for (let v of input) {
+ list[pos] = v;
+ yield* values(pos + 1);
+ }
}
}
- }
- yield* values(0);
- }
-
- // We're going to create a tree that looks like the
- // follwing.
- //
- // top sixth
- // / \
- // / \ /
- // first second
- // / \ /
- // / \
- // third fourth - - -
- // /
- // /
- // fifth
- //
- // The idea is to have one top level non-auxiliary browsing
- // context, five nested, one top level auxiliary with an
- // opener. Given that set of related browsing contexts we
- // wish to confirm that targeting is semantically equivalent
- // with how nsIDocShellTreeItem.findItemWithName works. The
- // trick to ensure that is to give all frames the same name!
- // and ensure that the find algorithms return the same nodes
- // in the same order.
-
- function bc(frame) {
- return (frame.contentWindow || frame).docShell.browsingContext;
- }
-
- let first = await addFrame(top, "first");
- let second = await addFrame(top, "second");
- let third = await addFrame(first, "third");
- let fourth = await addFrame(first, "fourth");
- let fifth = await addFrame(fourth, "fifth");
- let sixth = await addWindow(fourth, "sixth");
-
- let frames = [top, first, second, third, fourth, fifth, sixth];
- let browsingContexts = frames.map(bc);
- let docShells = browsingContexts.map(context => context.docShell);
-
- ok(top.docShell instanceof Ci.nsIDocShellTreeItem,
- "When we remove nsIDocShellTreeItem this test should be removed");
-
- // For every browsing context we generate all possible
- // combinations of names for these browsing contexts using
- // "dummy" and "target" as possible name.
- for (let names of generate(["dummy", "target"], docShells.length)) {
- for (let i = names.length - 1; i >= 0; --i) {
- docShells[i].name = names[i];
+ yield* values(0);
}
- for (let i = 0; i < docShells.length; ++i) {
- let docShell = docShells[i].findItemWithName("target", null, null, false);
- let browsingContext = browsingContexts[i].findWithName("target");
- is(docShell ? docShell.browsingContext : null, browsingContext,
- "findItemWithName should find same browsing context as findWithName");
- }
- }
+ // We're going to create a tree that looks like the
+ // follwing.
+ //
+ // top sixth
+ // / \
+ // / \ /
+ // first second
+ // / \ /
+ // / \
+ // third fourth - - -
+ // /
+ // /
+ // fifth
+ //
+ // The idea is to have one top level non-auxiliary browsing
+ // context, five nested, one top level auxiliary with an
+ // opener. Given that set of related browsing contexts we
+ // wish to confirm that targeting is semantically equivalent
+ // with how nsIDocShellTreeItem.findItemWithName works. The
+ // trick to ensure that is to give all frames the same name!
+ // and ensure that the find algorithms return the same nodes
+ // in the same order.
- for (let target of ["_self", "_top", "_parent", "_blank"]) {
- for (let i = 0; i < docShells.length; ++i) {
- let docShell = docShells[i].findItemWithName(target, null, null, false);
- let browsingContext = browsingContexts[i].findWithName(target);
- is(docShell ? docShell.browsingContext : null, browsingContext,
- "findItemWithName should find same browsing context as findWithName for " + target);
+ function bc(frame) {
+ return (frame.contentWindow || frame).docShell.browsingContext;
+ }
+
+ let first = await addFrame(top, "first");
+ let second = await addFrame(top, "second");
+ let third = await addFrame(first, "third");
+ let fourth = await addFrame(first, "fourth");
+ let fifth = await addFrame(fourth, "fifth");
+ let sixth = await addWindow(fourth, "sixth");
+
+ let frames = [top, first, second, third, fourth, fifth, sixth];
+ let browsingContexts = frames.map(bc);
+ let docShells = browsingContexts.map(context => context.docShell);
+
+ ok(
+ top.docShell instanceof Ci.nsIDocShellTreeItem,
+ "When we remove nsIDocShellTreeItem this test should be removed"
+ );
+
+ // For every browsing context we generate all possible
+ // combinations of names for these browsing contexts using
+ // "dummy" and "target" as possible name.
+ for (let names of generate(["dummy", "target"], docShells.length)) {
+ for (let i = names.length - 1; i >= 0; --i) {
+ docShells[i].name = names[i];
+ }
+
+ for (let i = 0; i < docShells.length; ++i) {
+ let docShell = docShells[i].findItemWithName(
+ "target",
+ null,
+ null,
+ false
+ );
+ let browsingContext = browsingContexts[i].findWithName("target");
+ is(
+ docShell ? docShell.browsingContext : null,
+ browsingContext,
+ "findItemWithName should find same browsing context as findWithName"
+ );
+ }
+ }
+
+ for (let target of ["_self", "_top", "_parent", "_blank"]) {
+ for (let i = 0; i < docShells.length; ++i) {
+ let docShell = docShells[i].findItemWithName(
+ target,
+ null,
+ null,
+ false
+ );
+ let browsingContext = browsingContexts[i].findWithName(target);
+ is(
+ docShell ? docShell.browsingContext : null,
+ browsingContext,
+ "findItemWithName should find same browsing context as findWithName for " +
+ target
+ );
+ }
}
}
- });
+ );
BrowserTestUtils.removeTab(await sixth);
- });
+ }
+ );
});
diff --git a/docshell/test/browser/browser_browsingContext-embedder.js b/docshell/test/browser/browser_browsingContext-embedder.js
index 0d29d096c640..7a8ff0f16948 100644
--- a/docshell/test/browser/browser_browsingContext-embedder.js
+++ b/docshell/test/browser/browser_browsingContext-embedder.js
@@ -12,8 +12,9 @@ function observeOnce(topic) {
}
add_task(async function setPrefs() {
- await SpecialPowers.pushPrefEnv({"set": [["fission.oopif.attribute", true],
- ["dom.ipc.processCount", 10000]]});
+ await SpecialPowers.pushPrefEnv({
+ set: [["fission.oopif.attribute", true], ["dom.ipc.processCount", 10000]],
+ });
});
add_task(async function runTest() {
@@ -25,13 +26,21 @@ add_task(async function runTest() {
is(chromeBC.parent, null, "chrome has no parent");
// Open a new tab, and check that basic frames work out.
- let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser});
+ let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser });
info(`root, parent`);
let rootBC = tab.linkedBrowser.browsingContext;
ok(rootBC.currentWindowGlobal, "[parent] root has a window global");
- is(rootBC.embedderWindowGlobal, chromeBC.currentWindowGlobal, "[parent] root has chrome as embedder global");
- is(rootBC.embedderElement, tab.linkedBrowser, "[parent] root has browser as embedder element");
+ is(
+ rootBC.embedderWindowGlobal,
+ chromeBC.currentWindowGlobal,
+ "[parent] root has chrome as embedder global"
+ );
+ is(
+ rootBC.embedderElement,
+ tab.linkedBrowser,
+ "[parent] root has browser as embedder element"
+ );
is(rootBC.parent, null, "[parent] root has no parent");
// Test with an in-process frame
@@ -55,7 +64,11 @@ add_task(async function runTest() {
info(`frame, parent`);
let frameBC = BrowsingContext.get(frameId);
ok(frameBC.currentWindowGlobal, "[parent] frame has a window global");
- is(frameBC.embedderWindowGlobal, rootBC.currentWindowGlobal, "[parent] frame has root as embedder global");
+ is(
+ frameBC.embedderWindowGlobal,
+ rootBC.currentWindowGlobal,
+ "[parent] frame has root as embedder global"
+ );
is(frameBC.embedderElement, null, "[parent] frame has no embedder element");
is(frameBC.parent, rootBC, "[parent] frame has root as parent");
@@ -86,20 +99,32 @@ add_task(async function runTest() {
info(`oop frame, child`);
let oopBC = oop.frameLoader.browsingContext;
is(oopBC.embedderElement, oop, "[child] oop frame embedded within iframe");
- is(oopBC.parent, content.docShell.browsingContext, "[child] frame has root as parent");
+ is(
+ oopBC.parent,
+ content.docShell.browsingContext,
+ "[child] frame has root as parent"
+ );
return oopBC.id;
});
info(`oop frame, parent`);
let oopBC = BrowsingContext.get(oopID);
- is(oopBC.embedderWindowGlobal, rootBC.currentWindowGlobal, "[parent] oop frame has root as embedder global");
+ is(
+ oopBC.embedderWindowGlobal,
+ rootBC.currentWindowGlobal,
+ "[parent] oop frame has root as embedder global"
+ );
is(oopBC.embedderElement, null, "[parent] oop frame has no embedder element");
is(oopBC.parent, rootBC, "[parent] oop frame has root as parent");
info(`waiting for oop window global`);
let oopWindowGlobal = await oopWindowGlobalPromise;
- is(oopBC.currentWindowGlobal, oopWindowGlobal, "[parent] oop frame has a window global");
+ is(
+ oopBC.currentWindowGlobal,
+ oopWindowGlobal,
+ "[parent] oop frame has a window global"
+ );
// Open a new window, and adopt |tab| into it.
@@ -108,7 +133,11 @@ add_task(async function runTest() {
info(`new chrome, parent`);
let newChromeBC = newWindow.docShell.browsingContext;
ok(newChromeBC.currentWindowGlobal, "Should have a current WindowGlobal");
- is(newChromeBC.embedderWindowGlobal, null, "new chrome has no embedder global");
+ is(
+ newChromeBC.embedderWindowGlobal,
+ null,
+ "new chrome has no embedder global"
+ );
is(newChromeBC.embedderElement, null, "new chrome has no embedder element");
is(newChromeBC.parent, null, "new chrome has no parent");
@@ -117,9 +146,21 @@ add_task(async function runTest() {
info(`adopting tab`);
let newTab = newWindow.gBrowser.adoptTab(tab);
- is(newTab.linkedBrowser.browsingContext, rootBC, "[parent] root browsing context survived");
- is(rootBC.embedderWindowGlobal, newChromeBC.currentWindowGlobal, "[parent] embedder window global updated");
- is(rootBC.embedderElement, newTab.linkedBrowser, "[parent] embedder element updated");
+ is(
+ newTab.linkedBrowser.browsingContext,
+ rootBC,
+ "[parent] root browsing context survived"
+ );
+ is(
+ rootBC.embedderWindowGlobal,
+ newChromeBC.currentWindowGlobal,
+ "[parent] embedder window global updated"
+ );
+ is(
+ rootBC.embedderElement,
+ newTab.linkedBrowser,
+ "[parent] embedder element updated"
+ );
is(rootBC.parent, null, "[parent] root has no parent");
info(`closing window`);
diff --git a/docshell/test/browser/browser_bug1206879.js b/docshell/test/browser/browser_bug1206879.js
index c036507fc1e3..0cc082a9012e 100644
--- a/docshell/test/browser/browser_bug1206879.js
+++ b/docshell/test/browser/browser_bug1206879.js
@@ -26,6 +26,9 @@ add_task(async function() {
gBrowser.removeTab(tab);
gBrowser.removeTabsProgressListener(listener);
- is(numLocationChanges, 1,
- "pushState with a different URI should cause a LocationChange event.");
+ is(
+ numLocationChanges,
+ 1,
+ "pushState with a different URI should cause a LocationChange event."
+ );
});
diff --git a/docshell/test/browser/browser_bug1309900_crossProcessHistoryNavigation.js b/docshell/test/browser/browser_bug1309900_crossProcessHistoryNavigation.js
index 06f9ab18c7b7..6bddef65e9bb 100644
--- a/docshell/test/browser/browser_bug1309900_crossProcessHistoryNavigation.js
+++ b/docshell/test/browser/browser_bug1309900_crossProcessHistoryNavigation.js
@@ -5,7 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(async function runTests() {
- let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:about");
+ let tab = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ "about:about"
+ );
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
@@ -21,10 +24,16 @@ add_task(async function runTests() {
// Using a dummy onunload listener to disable the bfcache as that can prevent
// the test browser load detection mechanism from working.
loaded = BrowserTestUtils.browserLoaded(browser);
- BrowserTestUtils.loadURI(browser, "data:text/html,");
+ BrowserTestUtils.loadURI(
+ browser,
+ "data:text/html,"
+ );
href = await loaded;
- is(href, "data:text/html,",
- "Check data URL loaded");
+ is(
+ href,
+ "data:text/html,",
+ "Check data URL loaded"
+ );
loaded = BrowserTestUtils.browserLoaded(browser);
browser.goBack();
@@ -34,6 +43,9 @@ add_task(async function runTests() {
loaded = BrowserTestUtils.browserLoaded(browser);
browser.goForward();
href = await loaded;
- is(href, "data:text/html,",
- "Check we've gone forward to data URL");
+ is(
+ href,
+ "data:text/html,",
+ "Check we've gone forward to data URL"
+ );
});
diff --git a/docshell/test/browser/browser_bug1328501.js b/docshell/test/browser/browser_bug1328501.js
index f1cfe6572490..b4431d1f67e0 100644
--- a/docshell/test/browser/browser_bug1328501.js
+++ b/docshell/test/browser/browser_bug1328501.js
@@ -1,14 +1,19 @@
-const HTML_URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug1328501.html";
-const FRAME_URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug1328501_frame.html";
-const FRAME_SCRIPT_URL = "chrome://mochitests/content/browser/docshell/test/browser/file_bug1328501_framescript.js";
+const HTML_URL =
+ "http://mochi.test:8888/browser/docshell/test/browser/file_bug1328501.html";
+const FRAME_URL =
+ "http://mochi.test:8888/browser/docshell/test/browser/file_bug1328501_frame.html";
+const FRAME_SCRIPT_URL =
+ "chrome://mochitests/content/browser/docshell/test/browser/file_bug1328501_framescript.js";
add_task(async function testMultiFrameRestore() {
- await BrowserTestUtils.withNewTab({gBrowser, url: HTML_URL}, async function(browser) {
+ await BrowserTestUtils.withNewTab({ gBrowser, url: HTML_URL }, async function(
+ browser
+ ) {
// Navigate 2 subframes and load about:blank.
let browserLoaded = BrowserTestUtils.browserLoaded(browser);
await ContentTask.spawn(browser, FRAME_URL, async function(FRAME_URL) {
function frameLoaded(frame) {
frame.contentWindow.location = FRAME_URL;
- return new Promise(r => frame.onload = r);
+ return new Promise(r => (frame.onload = r));
}
let frame1 = content.document.querySelector("#testFrame1");
let frame2 = content.document.querySelector("#testFrame2");
@@ -25,15 +30,26 @@ add_task(async function testMultiFrameRestore() {
browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
// The frame script also forwards frames-loaded.
- let framesLoaded = BrowserTestUtils.waitForMessage(browser.messageManager, "test:frames-loaded");
+ let framesLoaded = BrowserTestUtils.waitForMessage(
+ browser.messageManager,
+ "test:frames-loaded"
+ );
browser.goBack();
await framesLoaded;
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
await new Promise(r => setTimeout(r, 1000));
- await ContentTask.spawn(browser, FRAME_URL, (FRAME_URL) => {
- is(content.document.querySelector("#testFrame1").contentWindow.location.href, FRAME_URL);
- is(content.document.querySelector("#testFrame2").contentWindow.location.href, FRAME_URL);
+ await ContentTask.spawn(browser, FRAME_URL, FRAME_URL => {
+ is(
+ content.document.querySelector("#testFrame1").contentWindow.location
+ .href,
+ FRAME_URL
+ );
+ is(
+ content.document.querySelector("#testFrame2").contentWindow.location
+ .href,
+ FRAME_URL
+ );
});
});
});
diff --git a/docshell/test/browser/browser_bug1347823.js b/docshell/test/browser/browser_bug1347823.js
index e9141241d06f..966a11a7d39b 100644
--- a/docshell/test/browser/browser_bug1347823.js
+++ b/docshell/test/browser/browser_bug1347823.js
@@ -11,7 +11,7 @@ add_task(async function testValidCache() {
});
await BrowserTestUtils.withNewTab(
- {gBrowser, url: "data:text/html;charset=utf-8,page1"},
+ { gBrowser, url: "data:text/html;charset=utf-8,page1" },
async function(browser) {
// Make a simple modification for bfcache testing.
await ContentTask.spawn(browser, null, () => {
@@ -23,13 +23,17 @@ add_task(async function testValidCache() {
await BrowserTestUtils.browserLoaded(browser);
// Go back and verify text content.
- let awaitPageShow = BrowserTestUtils.waitForContentEvent(browser, "pageshow");
+ let awaitPageShow = BrowserTestUtils.waitForContentEvent(
+ browser,
+ "pageshow"
+ );
browser.goBack();
await awaitPageShow;
await ContentTask.spawn(browser, null, () => {
is(content.document.body.textContent, "modified");
});
- });
+ }
+ );
});
// With bfcache expired.
@@ -40,7 +44,7 @@ add_task(async function testExpiredCache() {
});
await BrowserTestUtils.withNewTab(
- {gBrowser, url: "data:text/html;charset=utf-8,page1"},
+ { gBrowser, url: "data:text/html;charset=utf-8,page1" },
async function(browser) {
// Make a simple modification for bfcache testing.
await ContentTask.spawn(browser, null, () => {
@@ -59,11 +63,15 @@ add_task(async function testExpiredCache() {
});
// Go back and verify text content.
- let awaitPageShow = BrowserTestUtils.waitForContentEvent(browser, "pageshow");
+ let awaitPageShow = BrowserTestUtils.waitForContentEvent(
+ browser,
+ "pageshow"
+ );
browser.goBack();
await awaitPageShow;
await ContentTask.spawn(browser, null, () => {
is(content.document.body.textContent, "page1");
});
- });
+ }
+ );
});
diff --git a/docshell/test/browser/browser_bug134911.js b/docshell/test/browser/browser_bug134911.js
index 40a9890529d2..24569292dedc 100644
--- a/docshell/test/browser/browser_bug134911.js
+++ b/docshell/test/browser/browser_bug134911.js
@@ -1,21 +1,28 @@
const TEXT = {
/* The test text decoded correctly as Shift_JIS */
- rightText: "\u30E6\u30CB\u30B3\u30FC\u30C9\u306F\u3001\u3059\u3079\u3066\u306E\u6587\u5B57\u306B\u56FA\u6709\u306E\u756A\u53F7\u3092\u4ED8\u4E0E\u3057\u307E\u3059",
+ rightText:
+ "\u30E6\u30CB\u30B3\u30FC\u30C9\u306F\u3001\u3059\u3079\u3066\u306E\u6587\u5B57\u306B\u56FA\u6709\u306E\u756A\u53F7\u3092\u4ED8\u4E0E\u3057\u307E\u3059",
enteredText1: "The quick brown fox jumps over the lazy dog",
- enteredText2: "\u03BE\u03B5\u03C3\u03BA\u03B5\u03C0\u03AC\u03B6\u03C9\u0020\u03C4\u1F74\u03BD\u0020\u03C8\u03C5\u03C7\u03BF\u03C6\u03B8\u03CC\u03C1\u03B1\u0020\u03B2\u03B4\u03B5\u03BB\u03C5\u03B3\u03BC\u03AF\u03B1",
+ enteredText2:
+ "\u03BE\u03B5\u03C3\u03BA\u03B5\u03C0\u03AC\u03B6\u03C9\u0020\u03C4\u1F74\u03BD\u0020\u03C8\u03C5\u03C7\u03BF\u03C6\u03B8\u03CC\u03C1\u03B1\u0020\u03B2\u03B4\u03B5\u03BB\u03C5\u03B3\u03BC\u03AF\u03B1",
};
function test() {
waitForExplicitFinish();
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, rootDir + "test-form_sjis.html");
+ gBrowser.selectedTab = BrowserTestUtils.addTab(
+ gBrowser,
+ rootDir + "test-form_sjis.html"
+ );
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterOpen);
}
function afterOpen() {
- BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterChangeCharset);
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(
+ afterChangeCharset
+ );
ContentTask.spawn(gBrowser.selectedBrowser, TEXT, function(TEXT) {
content.document.getElementById("testtextarea").value = TEXT.enteredText1;
@@ -28,12 +35,21 @@ function afterOpen() {
function afterChangeCharset() {
ContentTask.spawn(gBrowser.selectedBrowser, TEXT, function(TEXT) {
- is(content.document.getElementById("testpar").innerHTML, TEXT.rightText,
- "encoding successfully changed");
- is(content.document.getElementById("testtextarea").value, TEXT.enteredText1,
- "text preserved in