Bug 1561435 - Format caps/, a=automatic-formatting
authorVictor Porof <vporof@mozilla.com>
Fri, 05 Jul 2019 09:58:41 +0200
changeset 541038 0513b22f434f7b18b21d73deabfb62fd3cddbb74
parent 541037 dfb231a91cc39dc056617bf5c18006bcbb1cd2e8
child 541039 0bbd90cb5368ff59418cf16fcdadb2a59d61f18f
push id11533
push userarchaeopteryx@coole-files.de
push dateMon, 08 Jul 2019 18:18:03 +0000
treeherdermozilla-beta@f4452e031aed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatic-formatting
bugs1561435
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1561435 - Format caps/, a=automatic-formatting # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35897
.eslintrc.js
.prettierignore
caps/tests/mochitest/browser_aboutOrigin.js
caps/tests/mochitest/browser_checkloaduri.js
caps/tests/unit/test_origin.js
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -39,17 +39,16 @@ module.exports = {
   "extends": [
     "plugin:mozilla/recommended"
   ],
   "plugins": [
     "mozilla"
   ],
   "overrides": [{
       "files": [
-        "caps/**",
         "chrome/**",
         "config/**",
         "devtools/**",
         "docshell/**",
         "dom/**",
         "editor/**",
         "extensions/**",
         "gfx/**",
--- a/.prettierignore
+++ b/.prettierignore
@@ -35,17 +35,16 @@ security/manager/ssl/security-prefs.js
 services/common/services-common.js
 services/sync/services-sync.js
 services/sync/tests/unit/prefs_test_prefs_store.js
 testing/marionette/prefs/marionette.js
 toolkit/components/telemetry/datareporting-prefs.js
 toolkit/components/telemetry/healthreport-prefs.js
 
 # Ignore all top-level directories for now.
-caps/**
 chrome/**
 config/**
 docshell/**
 dom/**
 editor/**
 extensions/**
 gfx/**
 gradle/**
--- a/caps/tests/mochitest/browser_aboutOrigin.js
+++ b/caps/tests/mochitest/browser_aboutOrigin.js
@@ -1,11 +1,11 @@
 "use strict";
 
-let tests = [ "about:robots?foo", "about:robots#foo", "about:robots?foo#bar"];
+let tests = ["about:robots?foo", "about:robots#foo", "about:robots?foo#bar"];
 tests.forEach(async test => {
   add_task(async () => {
     await BrowserTestUtils.withNewTab(test, async browser => {
       await ContentTask.spawn(browser, null, () => {
         is(content.document.nodePrincipal.origin, "about:robots");
       });
     });
   });
--- a/caps/tests/mochitest/browser_checkloaduri.js
+++ b/caps/tests/mochitest/browser_checkloaduri.js
@@ -1,187 +1,249 @@
 "use strict";
 
 let ssm = Services.scriptSecurityManager;
 // This will show a directory listing, but we never actually load these so that's OK.
 const kDummyPage = getRootDirectory(gTestPath);
 
 const kAboutPagesRegistered = Promise.all([
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-chrome-privs", kDummyPage,
-    Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-chrome-privs",
+    kDummyPage,
+    Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-chrome-privs2", kDummyPage,
-    Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-chrome-privs2",
+    kDummyPage,
+    Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-unknown-linkable", kDummyPage,
-    Ci.nsIAboutModule.MAKE_LINKABLE | Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-unknown-linkable",
+    kDummyPage,
+    Ci.nsIAboutModule.MAKE_LINKABLE | Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-unknown-linkable2", kDummyPage,
-    Ci.nsIAboutModule.MAKE_LINKABLE | Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-unknown-linkable2",
+    kDummyPage,
+    Ci.nsIAboutModule.MAKE_LINKABLE | Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-unknown-unlinkable", kDummyPage,
-    Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-unknown-unlinkable",
+    kDummyPage,
+    Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-unknown-unlinkable2", kDummyPage,
-    Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-unknown-unlinkable2",
+    kDummyPage,
+    Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-content-unlinkable", kDummyPage,
-    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-content-unlinkable",
+    kDummyPage,
+    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
+      Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-content-unlinkable2", kDummyPage,
-    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-content-unlinkable2",
+    kDummyPage,
+    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
+      Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-content-linkable", kDummyPage,
-    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | Ci.nsIAboutModule.MAKE_LINKABLE |
-    Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-content-linkable",
+    kDummyPage,
+    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
+      Ci.nsIAboutModule.MAKE_LINKABLE |
+      Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
   BrowserTestUtils.registerAboutPage(
-    registerCleanupFunction, "test-content-linkable2", kDummyPage,
-    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | Ci.nsIAboutModule.MAKE_LINKABLE |
-    Ci.nsIAboutModule.ALLOW_SCRIPT),
+    registerCleanupFunction,
+    "test-content-linkable2",
+    kDummyPage,
+    Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
+      Ci.nsIAboutModule.MAKE_LINKABLE |
+      Ci.nsIAboutModule.ALLOW_SCRIPT
+  ),
 ]);
 
 const URLs = new Map([
-  ["http://www.example.com", [
-  // For each of these entries, the booleans represent whether the parent URI can:
-  // - load them
-  // - load them without principal inheritance
-  // - whether the URI can be created at all (some protocol handlers will
-  //   refuse to create certain variants)
-    ["http://www.example2.com", true, true, true],
-    ["https://www.example2.com", true, true, true],
-    ["moz-icon:file:///foo/bar/baz.exe", false, false, true],
-    ["moz-icon://.exe", false, false, true],
-    ["chrome://foo/content/bar.xul", false, false, true],
-    ["view-source:http://www.example2.com", false, false, true],
-    ["view-source:https://www.example2.com", false, false, true],
-    ["data:text/html,Hi", true, false, true],
-    ["view-source:data:text/html,Hi", false, false, true],
-    ["javascript:alert('hi')", true, false, true],
-    ["moz://a", false, false, true],
-    ["about:test-chrome-privs", false, false, true],
-    ["about:test-unknown-unlinkable", false, false, true],
-    ["about:test-content-unlinkable", false, false, true],
-    ["about:test-content-linkable", true, true, true],
-    // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
-    ["about:test-unknown-linkable", false, false, true],
-  ]],
-  ["view-source:http://www.example.com", [
-    ["http://www.example2.com", true, true, true],
-    ["https://www.example2.com", true, true, true],
-    ["moz-icon:file:///foo/bar/baz.exe", false, false, true],
-    ["moz-icon://.exe", false, false, true],
-    ["chrome://foo/content/bar.xul", false, false, true],
-    ["view-source:http://www.example2.com", true, true, true],
-    ["view-source:https://www.example2.com", true, true, true],
-    ["data:text/html,Hi", true, false, true],
-    ["view-source:data:text/html,Hi", true, false, true],
-    ["javascript:alert('hi')", true, false, true],
-    ["moz://a", false, false, true],
-    ["about:test-chrome-privs", false, false, true],
-    ["about:test-unknown-unlinkable", false, false, true],
-    ["about:test-content-unlinkable", false, false, true],
-    ["about:test-content-linkable", true, true, true],
-    // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
-    ["about:test-unknown-linkable", false, false, true],
-  ]],
+  [
+    "http://www.example.com",
+    [
+      // For each of these entries, the booleans represent whether the parent URI can:
+      // - load them
+      // - load them without principal inheritance
+      // - whether the URI can be created at all (some protocol handlers will
+      //   refuse to create certain variants)
+      ["http://www.example2.com", true, true, true],
+      ["https://www.example2.com", true, true, true],
+      ["moz-icon:file:///foo/bar/baz.exe", false, false, true],
+      ["moz-icon://.exe", false, false, true],
+      ["chrome://foo/content/bar.xul", false, false, true],
+      ["view-source:http://www.example2.com", false, false, true],
+      ["view-source:https://www.example2.com", false, false, true],
+      ["data:text/html,Hi", true, false, true],
+      ["view-source:data:text/html,Hi", false, false, true],
+      ["javascript:alert('hi')", true, false, true],
+      ["moz://a", false, false, true],
+      ["about:test-chrome-privs", false, false, true],
+      ["about:test-unknown-unlinkable", false, false, true],
+      ["about:test-content-unlinkable", false, false, true],
+      ["about:test-content-linkable", true, true, true],
+      // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
+      ["about:test-unknown-linkable", false, false, true],
+    ],
+  ],
+  [
+    "view-source:http://www.example.com",
+    [
+      ["http://www.example2.com", true, true, true],
+      ["https://www.example2.com", true, true, true],
+      ["moz-icon:file:///foo/bar/baz.exe", false, false, true],
+      ["moz-icon://.exe", false, false, true],
+      ["chrome://foo/content/bar.xul", false, false, true],
+      ["view-source:http://www.example2.com", true, true, true],
+      ["view-source:https://www.example2.com", true, true, true],
+      ["data:text/html,Hi", true, false, true],
+      ["view-source:data:text/html,Hi", true, false, true],
+      ["javascript:alert('hi')", true, false, true],
+      ["moz://a", false, false, true],
+      ["about:test-chrome-privs", false, false, true],
+      ["about:test-unknown-unlinkable", false, false, true],
+      ["about:test-content-unlinkable", false, false, true],
+      ["about:test-content-linkable", true, true, true],
+      // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
+      ["about:test-unknown-linkable", false, false, true],
+    ],
+  ],
   // about: related tests.
-  ["about:test-chrome-privs", [
-    ["about:test-chrome-privs", true, true, true],
-    ["about:test-chrome-privs2", true, true, true],
-    ["about:test-chrome-privs2?foo#bar", true, true, true],
-    ["about:test-chrome-privs2?foo", true, true, true],
-    ["about:test-chrome-privs2#bar", true, true, true],
+  [
+    "about:test-chrome-privs",
+    [
+      ["about:test-chrome-privs", true, true, true],
+      ["about:test-chrome-privs2", true, true, true],
+      ["about:test-chrome-privs2?foo#bar", true, true, true],
+      ["about:test-chrome-privs2?foo", true, true, true],
+      ["about:test-chrome-privs2#bar", true, true, true],
 
-    ["about:test-unknown-unlinkable", true, true, true],
+      ["about:test-unknown-unlinkable", true, true, true],
 
-    ["about:test-content-unlinkable", true, true, true],
-    ["about:test-content-unlinkable?foo", true, true, true],
-    ["about:test-content-unlinkable?foo#bar", true, true, true],
-    ["about:test-content-unlinkable#bar", true, true, true],
+      ["about:test-content-unlinkable", true, true, true],
+      ["about:test-content-unlinkable?foo", true, true, true],
+      ["about:test-content-unlinkable?foo#bar", true, true, true],
+      ["about:test-content-unlinkable#bar", true, true, true],
 
-    ["about:test-content-linkable", true, true, true],
+      ["about:test-content-linkable", true, true, true],
 
-    ["about:test-unknown-linkable", true, true, true],
-    ["moz-icon:file:///foo/bar/baz.exe", true, true, true],
-    ["moz-icon://.exe", true, true, true],
-  ]],
-  ["about:test-unknown-unlinkable", [
-    ["about:test-chrome-privs", false, false, true],
+      ["about:test-unknown-linkable", true, true, true],
+      ["moz-icon:file:///foo/bar/baz.exe", true, true, true],
+      ["moz-icon://.exe", true, true, true],
+    ],
+  ],
+  [
+    "about:test-unknown-unlinkable",
+    [
+      ["about:test-chrome-privs", false, false, true],
 
-    // Can link to ourselves:
-    ["about:test-unknown-unlinkable", true, true, true],
-    // Can't link to unlinkable content if we're not sure it's privileged:
-    ["about:test-unknown-unlinkable2", false, false, true],
+      // Can link to ourselves:
+      ["about:test-unknown-unlinkable", true, true, true],
+      // Can't link to unlinkable content if we're not sure it's privileged:
+      ["about:test-unknown-unlinkable2", false, false, true],
 
-    ["about:test-content-unlinkable", true, true, true],
-    ["about:test-content-unlinkable2", true, true, true],
-    ["about:test-content-unlinkable2?foo", true, true, true],
-    ["about:test-content-unlinkable2?foo#bar", true, true, true],
-    ["about:test-content-unlinkable2#bar", true, true, true],
+      ["about:test-content-unlinkable", true, true, true],
+      ["about:test-content-unlinkable2", true, true, true],
+      ["about:test-content-unlinkable2?foo", true, true, true],
+      ["about:test-content-unlinkable2?foo#bar", true, true, true],
+      ["about:test-content-unlinkable2#bar", true, true, true],
 
-    ["about:test-content-linkable", true, true, true],
+      ["about:test-content-linkable", true, true, true],
 
-    // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
-    ["about:test-unknown-linkable", false, false, true],
-  ]],
-  ["about:test-content-unlinkable", [
-    ["about:test-chrome-privs", false, false, true],
-
-    // Can't link to unlinkable content if we're not sure it's privileged:
-    ["about:test-unknown-unlinkable", false, false, true],
+      // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
+      ["about:test-unknown-linkable", false, false, true],
+    ],
+  ],
+  [
+    "about:test-content-unlinkable",
+    [
+      ["about:test-chrome-privs", false, false, true],
 
-    ["about:test-content-unlinkable", true, true, true],
-    ["about:test-content-unlinkable2", true, true, true],
-    ["about:test-content-unlinkable2?foo", true, true, true],
-    ["about:test-content-unlinkable2?foo#bar", true, true, true],
-    ["about:test-content-unlinkable2#bar", true, true, true],
+      // Can't link to unlinkable content if we're not sure it's privileged:
+      ["about:test-unknown-unlinkable", false, false, true],
 
-    ["about:test-content-linkable", true, true, true],
-    ["about:test-unknown-linkable", false, false, true],
-  ]],
-  ["about:test-unknown-linkable", [
-    ["about:test-chrome-privs", false, false, true],
+      ["about:test-content-unlinkable", true, true, true],
+      ["about:test-content-unlinkable2", true, true, true],
+      ["about:test-content-unlinkable2?foo", true, true, true],
+      ["about:test-content-unlinkable2?foo#bar", true, true, true],
+      ["about:test-content-unlinkable2#bar", true, true, true],
 
-    // Linkable content can't link to unlinkable content.
-    ["about:test-unknown-unlinkable", false, false, true],
+      ["about:test-content-linkable", true, true, true],
+      ["about:test-unknown-linkable", false, false, true],
+    ],
+  ],
+  [
+    "about:test-unknown-linkable",
+    [
+      ["about:test-chrome-privs", false, false, true],
 
-    ["about:test-content-unlinkable", false, false, true],
-    ["about:test-content-unlinkable2", false, false, true],
-    ["about:test-content-unlinkable2?foo", false, false, true],
-    ["about:test-content-unlinkable2?foo#bar", false, false, true],
-    ["about:test-content-unlinkable2#bar", false, false, true],
+      // Linkable content can't link to unlinkable content.
+      ["about:test-unknown-unlinkable", false, false, true],
 
-    // ... but it can link to other linkable content.
-    ["about:test-content-linkable", true, true, true],
+      ["about:test-content-unlinkable", false, false, true],
+      ["about:test-content-unlinkable2", false, false, true],
+      ["about:test-content-unlinkable2?foo", false, false, true],
+      ["about:test-content-unlinkable2?foo#bar", false, false, true],
+      ["about:test-content-unlinkable2#bar", false, false, true],
 
-    // Can link to ourselves:
-    ["about:test-unknown-linkable", true, true, true],
+      // ... but it can link to other linkable content.
+      ["about:test-content-linkable", true, true, true],
 
-    // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
-    ["about:test-unknown-linkable2", false, false, true],
-  ]],
-  ["about:test-content-linkable", [
-    ["about:test-chrome-privs", false, false, true],
+      // Can link to ourselves:
+      ["about:test-unknown-linkable", true, true, true],
 
-    // Linkable content can't link to unlinkable content.
-    ["about:test-unknown-unlinkable", false, false, true],
+      // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
+      ["about:test-unknown-linkable2", false, false, true],
+    ],
+  ],
+  [
+    "about:test-content-linkable",
+    [
+      ["about:test-chrome-privs", false, false, true],
 
-    ["about:test-content-unlinkable", false, false, true],
+      // Linkable content can't link to unlinkable content.
+      ["about:test-unknown-unlinkable", false, false, true],
+
+      ["about:test-content-unlinkable", false, false, true],
 
-    // ... but it can link to itself and other linkable content.
-    ["about:test-content-linkable", true, true, true],
-    ["about:test-content-linkable2", true, true, true],
+      // ... but it can link to itself and other linkable content.
+      ["about:test-content-linkable", true, true, true],
+      ["about:test-content-linkable2", true, true, true],
 
-    // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
-    ["about:test-unknown-linkable", false, false, true],
-  ]],
+      // Because this page doesn't have SAFE_FOR_UNTRUSTED, the web can't link to it:
+      ["about:test-unknown-linkable", false, false, true],
+    ],
+  ],
 ]);
 
-function testURL(source, target, canLoad, canLoadWithoutInherit, canCreate, flags) {
+function testURL(
+  source,
+  target,
+  canLoad,
+  canLoadWithoutInherit,
+  canCreate,
+  flags
+) {
   function getPrincipalDesc(principal) {
     if (principal.URI) {
       return principal.URI.spec;
     }
     if (principal.isSystemPrincipal) {
       return "system principal";
     }
     if (principal.isNullPrincipal) {
@@ -189,74 +251,130 @@ function testURL(source, target, canLoad
     }
     return "unknown principal";
   }
   let threw = false;
   let targetURI;
   try {
     targetURI = makeURI(target);
   } catch (ex) {
-    ok(!canCreate, "Shouldn't be passing URIs that we can't create. Failed to create: " + target);
+    ok(
+      !canCreate,
+      "Shouldn't be passing URIs that we can't create. Failed to create: " +
+        target
+    );
     return;
   }
-  ok(canCreate, "Created a URI for " + target + " which should " +
-     (canCreate ? "" : "not ") + "be possible.");
+  ok(
+    canCreate,
+    "Created a URI for " +
+      target +
+      " which should " +
+      (canCreate ? "" : "not ") +
+      "be possible."
+  );
   try {
     ssm.checkLoadURIWithPrincipal(source, targetURI, flags);
   } catch (ex) {
     info(ex.message);
     threw = true;
   }
   let inheritDisallowed = flags & ssm.DISALLOW_INHERIT_PRINCIPAL;
   let shouldThrow = inheritDisallowed ? !canLoadWithoutInherit : !canLoad;
-  ok(threw == shouldThrow,
-     "Should " + (shouldThrow ? "" : "not ") + "throw an error when loading " +
-     target + " from " + getPrincipalDesc(source) +
-     (inheritDisallowed ? " without" : " with") + " principal inheritance.");
+  ok(
+    threw == shouldThrow,
+    "Should " +
+      (shouldThrow ? "" : "not ") +
+      "throw an error when loading " +
+      target +
+      " from " +
+      getPrincipalDesc(source) +
+      (inheritDisallowed ? " without" : " with") +
+      " principal inheritance."
+  );
 }
 
 add_task(async function() {
   await kAboutPagesRegistered;
   let baseFlags = ssm.STANDARD | ssm.DONT_REPORT_ERRORS;
   for (let [sourceString, targetsAndExpectations] of URLs) {
     let source;
     if (sourceString.startsWith("about:test-chrome-privs")) {
       source = ssm.getSystemPrincipal();
     } else {
       source = ssm.createCodebasePrincipal(makeURI(sourceString), {});
     }
-    for (let [target, canLoad, canLoadWithoutInherit, canCreate] of targetsAndExpectations) {
-      testURL(source, target, canLoad, canLoadWithoutInherit, canCreate, baseFlags);
-      testURL(source, target, canLoad, canLoadWithoutInherit, canCreate,
-              baseFlags | ssm.DISALLOW_INHERIT_PRINCIPAL);
+    for (let [
+      target,
+      canLoad,
+      canLoadWithoutInherit,
+      canCreate,
+    ] of targetsAndExpectations) {
+      testURL(
+        source,
+        target,
+        canLoad,
+        canLoadWithoutInherit,
+        canCreate,
+        baseFlags
+      );
+      testURL(
+        source,
+        target,
+        canLoad,
+        canLoadWithoutInherit,
+        canCreate,
+        baseFlags | ssm.DISALLOW_INHERIT_PRINCIPAL
+      );
     }
   }
 
   // Now test blob URIs, which we need to do in-content.
-  await BrowserTestUtils.withNewTab("http://www.example.com/", async function(browser) {
-    await ContentTask.spawn(
-      browser,
-      testURL.toString(),
-      async function(testURLFn) {
-        // eslint-disable-next-line no-shadow , no-eval
-        let testURL = eval("(" + testURLFn + ")");
-        // eslint-disable-next-line no-shadow
-        let ssm = Services.scriptSecurityManager;
-        // eslint-disable-next-line no-shadow
-        let baseFlags = ssm.STANDARD | ssm.DONT_REPORT_ERRORS;
-        // eslint-disable-next-line no-unused-vars
-        let makeURI = ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm", {}).BrowserUtils.makeURI;
-        let b = new content.Blob(["I am a blob"]);
-        let contentBlobURI = content.URL.createObjectURL(b);
-        let contentPrincipal = content.document.nodePrincipal;
-        // Loading this blob URI from the content page should work:
-        testURL(contentPrincipal, contentBlobURI, true, true, true, baseFlags);
-        testURL(contentPrincipal, contentBlobURI, true, true, true,
-                baseFlags | ssm.DISALLOW_INHERIT_PRINCIPAL);
+  await BrowserTestUtils.withNewTab("http://www.example.com/", async function(
+    browser
+  ) {
+    await ContentTask.spawn(browser, testURL.toString(), async function(
+      testURLFn
+    ) {
+      // eslint-disable-next-line no-shadow , no-eval
+      let testURL = eval("(" + testURLFn + ")");
+      // eslint-disable-next-line no-shadow
+      let ssm = Services.scriptSecurityManager;
+      // eslint-disable-next-line no-shadow
+      let baseFlags = ssm.STANDARD | ssm.DONT_REPORT_ERRORS;
+      // eslint-disable-next-line no-unused-vars
+      let makeURI = ChromeUtils.import(
+        "resource://gre/modules/BrowserUtils.jsm",
+        {}
+      ).BrowserUtils.makeURI;
+      let b = new content.Blob(["I am a blob"]);
+      let contentBlobURI = content.URL.createObjectURL(b);
+      let contentPrincipal = content.document.nodePrincipal;
+      // Loading this blob URI from the content page should work:
+      testURL(contentPrincipal, contentBlobURI, true, true, true, baseFlags);
+      testURL(
+        contentPrincipal,
+        contentBlobURI,
+        true,
+        true,
+        true,
+        baseFlags | ssm.DISALLOW_INHERIT_PRINCIPAL
+      );
 
-        testURL(contentPrincipal, "view-source:" + contentBlobURI, false, false, true,
-                baseFlags);
-        testURL(contentPrincipal, "view-source:" + contentBlobURI, false, false, true,
-                baseFlags | ssm.DISALLOW_INHERIT_PRINCIPAL);
-      }
-    );
+      testURL(
+        contentPrincipal,
+        "view-source:" + contentBlobURI,
+        false,
+        false,
+        true,
+        baseFlags
+      );
+      testURL(
+        contentPrincipal,
+        "view-source:" + contentBlobURI,
+        false,
+        false,
+        true,
+        baseFlags | ssm.DISALLOW_INHERIT_PRINCIPAL
+      );
+    });
   });
 });
--- a/caps/tests/unit/test_origin.js
+++ b/caps/tests/unit/test_origin.js
@@ -1,156 +1,260 @@
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var ssm = Services.scriptSecurityManager;
-function makeURI(uri) { return Services.io.newURI(uri); }
+function makeURI(uri) {
+  return Services.io.newURI(uri);
+}
 
 function checkThrows(f) {
   var threw = false;
-  try { f(); } catch (e) { threw = true; }
+  try {
+    f();
+  } catch (e) {
+    threw = true;
+  }
   Assert.ok(threw);
 }
 
 function checkCrossOrigin(a, b) {
   Assert.ok(!a.equals(b));
   Assert.ok(!a.equalsConsideringDomain(b));
   Assert.ok(!a.subsumes(b));
   Assert.ok(!a.subsumesConsideringDomain(b));
   Assert.ok(!b.subsumes(a));
   Assert.ok(!b.subsumesConsideringDomain(a));
 }
 
 function checkOriginAttributes(prin, attrs, suffix) {
   attrs = attrs || {};
-  Assert.equal(prin.originAttributes.inIsolatedMozBrowser, attrs.inIsolatedMozBrowser || false);
+  Assert.equal(
+    prin.originAttributes.inIsolatedMozBrowser,
+    attrs.inIsolatedMozBrowser || false
+  );
   Assert.equal(prin.originSuffix, suffix || "");
   Assert.equal(ChromeUtils.originAttributesToSuffix(attrs), suffix || "");
-  Assert.ok(ChromeUtils.originAttributesMatchPattern(prin.originAttributes, attrs));
+  Assert.ok(
+    ChromeUtils.originAttributesMatchPattern(prin.originAttributes, attrs)
+  );
   if (!prin.isNullPrincipal && !prin.origin.startsWith("[")) {
     Assert.ok(ssm.createCodebasePrincipalFromOrigin(prin.origin).equals(prin));
   } else {
     checkThrows(() => ssm.createCodebasePrincipalFromOrigin(prin.origin));
   }
 }
 
 function checkSandboxOriginAttributes(arr, attrs, options) {
   options = options || {};
   var sandbox = Cu.Sandbox(arr, options);
-  checkOriginAttributes(Cu.getObjectPrincipal(sandbox), attrs,
-                        ChromeUtils.originAttributesToSuffix(attrs));
+  checkOriginAttributes(
+    Cu.getObjectPrincipal(sandbox),
+    attrs,
+    ChromeUtils.originAttributesToSuffix(attrs)
+  );
 }
 
 // utility function useful for debugging
 function printAttrs(name, attrs) {
-  info(name + " {\n" +
-       "\tuserContextId: " + attrs.userContextId + ",\n" +
-       "\tinIsolatedMozBrowser: " + attrs.inIsolatedMozBrowser + ",\n" +
-       "\tprivateBrowsingId: '" + attrs.privateBrowsingId + "',\n" +
-       "\tfirstPartyDomain: '" + attrs.firstPartyDomain + "'\n}");
+  info(
+    name +
+      " {\n" +
+      "\tuserContextId: " +
+      attrs.userContextId +
+      ",\n" +
+      "\tinIsolatedMozBrowser: " +
+      attrs.inIsolatedMozBrowser +
+      ",\n" +
+      "\tprivateBrowsingId: '" +
+      attrs.privateBrowsingId +
+      "',\n" +
+      "\tfirstPartyDomain: '" +
+      attrs.firstPartyDomain +
+      "'\n}"
+  );
 }
 
-
 function checkValues(attrs, values) {
   values = values || {};
   // printAttrs("attrs", attrs);
   // printAttrs("values", values);
   Assert.equal(attrs.userContextId, values.userContextId || 0);
-  Assert.equal(attrs.inIsolatedMozBrowser, values.inIsolatedMozBrowser || false);
+  Assert.equal(
+    attrs.inIsolatedMozBrowser,
+    values.inIsolatedMozBrowser || false
+  );
   Assert.equal(attrs.privateBrowsingId, values.privateBrowsingId || "");
   Assert.equal(attrs.firstPartyDomain, values.firstPartyDomain || "");
 }
 
 function run_test() {
   // Attributeless origins.
   Assert.equal(ssm.getSystemPrincipal().origin, "[System Principal]");
   checkOriginAttributes(ssm.getSystemPrincipal());
-  var exampleOrg = ssm.createCodebasePrincipal(makeURI("http://example.org"), {});
+  var exampleOrg = ssm.createCodebasePrincipal(
+    makeURI("http://example.org"),
+    {}
+  );
   Assert.equal(exampleOrg.origin, "http://example.org");
   checkOriginAttributes(exampleOrg);
-  var exampleCom = ssm.createCodebasePrincipal(makeURI("https://www.example.com:123"), {});
+  var exampleCom = ssm.createCodebasePrincipal(
+    makeURI("https://www.example.com:123"),
+    {}
+  );
   Assert.equal(exampleCom.origin, "https://www.example.com:123");
   checkOriginAttributes(exampleCom);
   var nullPrin = Cu.getObjectPrincipal(new Cu.Sandbox(null));
-  Assert.ok(/^moz-nullprincipal:\{([0-9]|[a-z]|\-){36}\}$/.test(nullPrin.origin));
+  Assert.ok(
+    /^moz-nullprincipal:\{([0-9]|[a-z]|\-){36}\}$/.test(nullPrin.origin)
+  );
   checkOriginAttributes(nullPrin);
-  var ipv6Prin = ssm.createCodebasePrincipal(makeURI("https://[2001:db8::ff00:42:8329]:123"), {});
+  var ipv6Prin = ssm.createCodebasePrincipal(
+    makeURI("https://[2001:db8::ff00:42:8329]:123"),
+    {}
+  );
   Assert.equal(ipv6Prin.origin, "https://[2001:db8::ff00:42:8329]:123");
   checkOriginAttributes(ipv6Prin);
-  var ipv6NPPrin = ssm.createCodebasePrincipal(makeURI("https://[2001:db8::ff00:42:8329]"), {});
+  var ipv6NPPrin = ssm.createCodebasePrincipal(
+    makeURI("https://[2001:db8::ff00:42:8329]"),
+    {}
+  );
   Assert.equal(ipv6NPPrin.origin, "https://[2001:db8::ff00:42:8329]");
   checkOriginAttributes(ipv6NPPrin);
-  var ep = Cu.getObjectPrincipal(Cu.Sandbox([exampleCom, nullPrin, exampleOrg]));
+  var ep = Cu.getObjectPrincipal(
+    Cu.Sandbox([exampleCom, nullPrin, exampleOrg])
+  );
   checkOriginAttributes(ep);
   checkCrossOrigin(exampleCom, exampleOrg);
   checkCrossOrigin(exampleOrg, nullPrin);
 
   // nsEP origins should be in lexical order.
-  Assert.equal(ep.origin, `[Expanded Principal [${exampleOrg.origin}, ${exampleCom.origin}, ${nullPrin.origin}]]`);
+  Assert.equal(
+    ep.origin,
+    `[Expanded Principal [${exampleOrg.origin}, ${exampleCom.origin}, ${
+      nullPrin.origin
+    }]]`
+  );
 
   // Make sure createCodebasePrincipal does what the rest of gecko does.
-  Assert.ok(exampleOrg.equals(Cu.getObjectPrincipal(new Cu.Sandbox("http://example.org"))));
+  Assert.ok(
+    exampleOrg.equals(
+      Cu.getObjectPrincipal(new Cu.Sandbox("http://example.org"))
+    )
+  );
 
   //
   // Test origin attributes.
   //
 
   // Just browser.
-  var exampleOrg_browser = ssm.createCodebasePrincipal(makeURI("http://example.org"), {inIsolatedMozBrowser: true});
-  var nullPrin_browser = ssm.createNullPrincipal({inIsolatedMozBrowser: true});
-  checkOriginAttributes(exampleOrg_browser, {inIsolatedMozBrowser: true}, "^inBrowser=1");
-  checkOriginAttributes(nullPrin_browser, {inIsolatedMozBrowser: true}, "^inBrowser=1");
+  var exampleOrg_browser = ssm.createCodebasePrincipal(
+    makeURI("http://example.org"),
+    { inIsolatedMozBrowser: true }
+  );
+  var nullPrin_browser = ssm.createNullPrincipal({
+    inIsolatedMozBrowser: true,
+  });
+  checkOriginAttributes(
+    exampleOrg_browser,
+    { inIsolatedMozBrowser: true },
+    "^inBrowser=1"
+  );
+  checkOriginAttributes(
+    nullPrin_browser,
+    { inIsolatedMozBrowser: true },
+    "^inBrowser=1"
+  );
   Assert.equal(exampleOrg_browser.origin, "http://example.org^inBrowser=1");
 
   // First party Uri
-  var exampleOrg_firstPartyDomain = ssm.createCodebasePrincipal(makeURI("http://example.org"), {firstPartyDomain: "example.org"});
-  checkOriginAttributes(exampleOrg_firstPartyDomain, { firstPartyDomain: "example.org" }, "^firstPartyDomain=example.org");
-  Assert.equal(exampleOrg_firstPartyDomain.origin, "http://example.org^firstPartyDomain=example.org");
+  var exampleOrg_firstPartyDomain = ssm.createCodebasePrincipal(
+    makeURI("http://example.org"),
+    { firstPartyDomain: "example.org" }
+  );
+  checkOriginAttributes(
+    exampleOrg_firstPartyDomain,
+    { firstPartyDomain: "example.org" },
+    "^firstPartyDomain=example.org"
+  );
+  Assert.equal(
+    exampleOrg_firstPartyDomain.origin,
+    "http://example.org^firstPartyDomain=example.org"
+  );
 
   // Just userContext.
-  var exampleOrg_userContext = ssm.createCodebasePrincipal(makeURI("http://example.org"), {userContextId: 42});
-  checkOriginAttributes(exampleOrg_userContext, { userContextId: 42 }, "^userContextId=42");
-  Assert.equal(exampleOrg_userContext.origin, "http://example.org^userContextId=42");
+  var exampleOrg_userContext = ssm.createCodebasePrincipal(
+    makeURI("http://example.org"),
+    { userContextId: 42 }
+  );
+  checkOriginAttributes(
+    exampleOrg_userContext,
+    { userContextId: 42 },
+    "^userContextId=42"
+  );
+  Assert.equal(
+    exampleOrg_userContext.origin,
+    "http://example.org^userContextId=42"
+  );
 
   checkSandboxOriginAttributes(null, {});
   checkSandboxOriginAttributes("http://example.org", {});
-  checkSandboxOriginAttributes("http://example.org", {}, {originAttributes: {}});
+  checkSandboxOriginAttributes(
+    "http://example.org",
+    {},
+    { originAttributes: {} }
+  );
   checkSandboxOriginAttributes(["http://example.org"], {});
-  checkSandboxOriginAttributes(["http://example.org"], {}, {originAttributes: {}});
+  checkSandboxOriginAttributes(
+    ["http://example.org"],
+    {},
+    { originAttributes: {} }
+  );
 
   // Check that all of the above are cross-origin.
   checkCrossOrigin(exampleOrg_browser, nullPrin_browser);
   checkCrossOrigin(exampleOrg_firstPartyDomain, exampleOrg);
   checkCrossOrigin(exampleOrg_userContext, exampleOrg);
 
   // Check Principal kinds.
   function checkKind(prin, kind) {
     Assert.equal(prin.isNullPrincipal, kind == "nullPrincipal");
     Assert.equal(prin.isCodebasePrincipal, kind == "codebasePrincipal");
     Assert.equal(prin.isExpandedPrincipal, kind == "expandedPrincipal");
     Assert.equal(prin.isSystemPrincipal, kind == "systemPrincipal");
   }
   checkKind(ssm.createNullPrincipal({}), "nullPrincipal");
-  checkKind(ssm.createCodebasePrincipal(makeURI("http://www.example.com"), {}), "codebasePrincipal");
-  checkKind(Cu.getObjectPrincipal(Cu.Sandbox([ssm.createCodebasePrincipal(makeURI("http://www.example.com"), {})])), "expandedPrincipal");
+  checkKind(
+    ssm.createCodebasePrincipal(makeURI("http://www.example.com"), {}),
+    "codebasePrincipal"
+  );
+  checkKind(
+    Cu.getObjectPrincipal(
+      Cu.Sandbox([
+        ssm.createCodebasePrincipal(makeURI("http://www.example.com"), {}),
+      ])
+    ),
+    "expandedPrincipal"
+  );
   checkKind(ssm.getSystemPrincipal(), "systemPrincipal");
 
   //
   // Test Origin Attribute Manipulation
   //
 
   // check that we can create an empty origin attributes dict with default
   // members and values.
   var emptyAttrs = ChromeUtils.fillNonDefaultOriginAttributes({});
   checkValues(emptyAttrs);
 
   var uri = "http://example.org";
   var tests = [
-    [ "", {} ],
-    [ "^userContextId=3", {userContextId: 3} ],
-    [ "^inBrowser=1", {inIsolatedMozBrowser: true} ],
-    [ "^firstPartyDomain=example.org", {firstPartyDomain: "example.org"} ] ];
+    ["", {}],
+    ["^userContextId=3", { userContextId: 3 }],
+    ["^inBrowser=1", { inIsolatedMozBrowser: true }],
+    ["^firstPartyDomain=example.org", { firstPartyDomain: "example.org" }],
+  ];
 
   // check that we can create an origin attributes from an origin properly
   tests.forEach(t => {
     let attrs = ChromeUtils.createOriginAttributesFromOrigin(uri + t[0]);
     checkValues(attrs, t[1]);
     Assert.equal(ChromeUtils.originAttributesToSuffix(attrs), t[0]);
   });
 
@@ -162,18 +266,19 @@ function run_test() {
   });
 
   // each row in the dflt_tests array has these values:
   // [0] - the suffix used to create an origin attribute from
   // [1] - the expected result of creating an origin attributes from [0]
   // [2] - the expected result after setting userContextId to the default
   // [3] - the expected result of creating a suffix from [2]
   var dflt_tests = [
-    [ "", {}, {}, "" ],
-    [ "^userContextId=3", {userContextId: 3}, {}, "" ] ];
+    ["", {}, {}, ""],
+    ["^userContextId=3", { userContextId: 3 }, {}, ""],
+  ];
 
   // check that we can set the userContextId to default properly
   dflt_tests.forEach(t => {
     let orig = ChromeUtils.createOriginAttributesFromOrigin(uri + t[0]);
     checkValues(orig, t[1]);
     let mod = orig;
     mod.userContextId = 0;
     checkValues(mod, t[2]);
@@ -181,18 +286,19 @@ function run_test() {
   });
 
   // each row in the dflt2_tests array has these values:
   // [0] - the suffix used to create an origin attribute from
   // [1] - the expected result of creating an origin attributes from [0]
   // [2] - the expected result after setting firstPartyUri to the default
   // [3] - the expected result of creating a suffix from [2]
   var dflt2_tests = [
-    [ "", {}, {}, "" ],
-    [ "^firstPartyDomain=foo.com", {firstPartyDomain: "foo.com"}, {}, "" ] ];
+    ["", {}, {}, ""],
+    ["^firstPartyDomain=foo.com", { firstPartyDomain: "foo.com" }, {}, ""],
+  ];
 
   // check that we can set the userContextId to default properly
   dflt2_tests.forEach(t => {
     let orig = ChromeUtils.createOriginAttributesFromOrigin(uri + t[0]);
     checkValues(orig, t[1]);
     let mod = orig;
     mod.firstPartyDomain = "";
     checkValues(mod, t[2]);
@@ -208,10 +314,12 @@ function run_test() {
     Services.prefs.setBoolPref("security.fileuri.strict_origin_policy", t[0]);
     var filePrin = ssm.createCodebasePrincipal(fileURI, {});
     Assert.equal(filePrin.origin, t[1]);
   });
   Services.prefs.clearUserPref("security.fileuri.strict_origin_policy");
 
   var aboutBlankURI = makeURI("about:blank");
   var aboutBlankPrin = ssm.createCodebasePrincipal(aboutBlankURI, {});
-  Assert.ok(/^moz-nullprincipal:\{([0-9]|[a-z]|\-){36}\}$/.test(aboutBlankPrin.origin));
+  Assert.ok(
+    /^moz-nullprincipal:\{([0-9]|[a-z]|\-){36}\}$/.test(aboutBlankPrin.origin)
+  );
 }