Bug 1561435 - Format toolkit/forgetaboutsite/, a=automatic-formatting
authorVictor Porof <vporof@mozilla.com>
Fri, 05 Jul 2019 11:15:13 +0200
changeset 544279 b8561ed633b2d32582f0503e60aae8c95bda9ba4
parent 544278 7f9969319147bff459f4c97bcb85fc2637189805
child 544280 e5be4c59b7f15f98fabb32a68fc64050ddb62bcb
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [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 toolkit/forgetaboutsite/, a=automatic-formatting # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D36055
toolkit/forgetaboutsite/ForgetAboutSite.jsm
toolkit/forgetaboutsite/test/browser/browser_clearplugindata.js
toolkit/forgetaboutsite/test/browser/browser_cookieDomain.js
toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js
toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
--- a/toolkit/forgetaboutsite/ForgetAboutSite.jsm
+++ b/toolkit/forgetaboutsite/ForgetAboutSite.jsm
@@ -1,31 +1,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var EXPORTED_SYMBOLS = ["ForgetAboutSite"];
 
 var ForgetAboutSite = {
   async removeDataFromDomain(aDomain) {
     let errorCount = await new Promise(resolve => {
-      Services.clearData.deleteDataFromHost(aDomain, true /* user request */,
-                                            Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
-                                            errorCode => resolve(bitCounting(errorCode)));
+      Services.clearData.deleteDataFromHost(
+        aDomain,
+        true /* user request */,
+        Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
+        errorCode => resolve(bitCounting(errorCode))
+      );
     });
 
     if (errorCount !== 0) {
-      throw new Error(`There were a total of ${errorCount} errors during removal`);
+      throw new Error(
+        `There were a total of ${errorCount} errors during removal`
+      );
     }
   },
 };
 
 function bitCounting(value) {
   // To know more about how to count bits set to 1 in a numeric value, see this
   // interesting article:
   // https://blogs.msdn.microsoft.com/jeuge/2005/06/08/bit-fiddling-3/
-  const count = value - ((value >> 1) & 0o33333333333) - ((value >> 2) & 0o11111111111);
+  const count =
+    value - ((value >> 1) & 0o33333333333) - ((value >> 2) & 0o11111111111);
   return ((count + (count >> 3)) & 0o30707070707) % 63;
 }
--- a/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.js
+++ b/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.js
@@ -1,35 +1,41 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-let {ForgetAboutSite} = ChromeUtils.import("resource://gre/modules/ForgetAboutSite.jsm");
+let { ForgetAboutSite } = ChromeUtils.import(
+  "resource://gre/modules/ForgetAboutSite.jsm"
+);
 
 // Test clearing plugin data by domain using ForgetAboutSite.
-const testURL = "http://mochi.test:8888/browser/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.html";
+const testURL =
+  "http://mochi.test:8888/browser/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.html";
 
 const pluginHostIface = Ci.nsIPluginHost;
 var pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
 pluginHost.QueryInterface(pluginHostIface);
 
 var pluginTag;
 
 function stored(needles) {
   var something = pluginHost.siteHasData(this.pluginTag, null);
-  if (!needles)
+  if (!needles) {
     return something;
+  }
 
-  if (!something)
+  if (!something) {
     return false;
+  }
 
   for (var i = 0; i < needles.length; ++i) {
-    if (!pluginHost.siteHasData(this.pluginTag, needles[i]))
+    if (!pluginHost.siteHasData(this.pluginTag, needles[i])) {
       return false;
+    }
   }
   return true;
 }
 
 function setTestPluginEnabledState(newEnabledState, plugin) {
   var oldEnabledState = plugin.enabledState;
   plugin.enabledState = newEnabledState;
   SimpleTest.registerCleanupFunction(function() {
@@ -53,27 +59,35 @@ add_task(async function() {
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, pluginTag);
   await BrowserTestUtils.openNewForegroundTab(gBrowser, testURL);
 
   // Set data for the plugin after the page load.
   await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
     content.wrappedJSObject.testSteps();
   });
 
-  ok(stored(["192.168.1.1", "foo.com", "nonexistent.foo.com", "bar.com", "localhost"]),
-    "Data stored for sites");
+  ok(
+    stored([
+      "192.168.1.1",
+      "foo.com",
+      "nonexistent.foo.com",
+      "bar.com",
+      "localhost",
+    ]),
+    "Data stored for sites"
+  );
 
   // Clear data for "foo.com" and its subdomains.
   await ForgetAboutSite.removeDataFromDomain("foo.com");
 
   ok(stored(["bar.com", "192.168.1.1", "localhost"]), "Data stored for sites");
   ok(!stored(["foo.com"]), "Data cleared for foo.com");
   ok(!stored(["bar.foo.com"]), "Data cleared for subdomains of foo.com");
 
-    // Clear data for "bar.com" using a subdomain.
+  // Clear data for "bar.com" using a subdomain.
   await ForgetAboutSite.removeDataFromDomain("foo.bar.com");
   ok(!stored(["bar.com"]), "Data cleared for bar.com");
 
   // Clear data for "192.168.1.1".
   await ForgetAboutSite.removeDataFromDomain("192.168.1.1");
   ok(!stored(["192.168.1.1"]), "Data cleared for 192.168.1.1");
 
   // Clear data for "localhost".
--- a/toolkit/forgetaboutsite/test/browser/browser_cookieDomain.js
+++ b/toolkit/forgetaboutsite/test/browser/browser_cookieDomain.js
@@ -1,35 +1,50 @@
-let {ForgetAboutSite} = ChromeUtils.import("resource://gre/modules/ForgetAboutSite.jsm");
+let { ForgetAboutSite } = ChromeUtils.import(
+  "resource://gre/modules/ForgetAboutSite.jsm"
+);
 
 function checkCookie(host, originAttributes) {
   for (let cookie of Services.cookies.enumerator) {
-    if (ChromeUtils.isOriginAttributesEqual(originAttributes,
-                                            cookie.originAttributes) &&
-        cookie.host.includes(host)) {
+    if (
+      ChromeUtils.isOriginAttributesEqual(
+        originAttributes,
+        cookie.originAttributes
+      ) &&
+      cookie.host.includes(host)
+    ) {
       return true;
     }
   }
   return false;
 }
 
 add_task(async _ => {
   info("Test single cookie domain");
 
   // Let's clean up all the data.
   await new Promise(resolve => {
     Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
   });
 
   // A cookie domain
-  Services.cookies.add(".example.com", "/test", "foo", "bar",
-    false, false, false, Date.now() + 24000 * 60 * 60, {},
-    Ci.nsICookie.SAMESITE_NONE);
+  Services.cookies.add(
+    ".example.com",
+    "/test",
+    "foo",
+    "bar",
+    false,
+    false,
+    false,
+    Date.now() + 24000 * 60 * 60,
+    {},
+    Ci.nsICookie.SAMESITE_NONE
+  );
 
   // Cleaning up.
   await ForgetAboutSite.removeDataFromDomain("example.com");
 
   // All good.
   ok(!checkCookie("example.com", {}), "No cookies");
 
   // Clean up.
-  await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
+  await Sanitizer.sanitize(["cookies", "offlineApps"]);
 });
--- a/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js
+++ b/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js
@@ -5,28 +5,30 @@
 /* import-globals-from ../../../../dom/push/test/xpcshell/head.js */
 
 var profileDir = do_get_profile();
 
 /**
  * Removes any files that could make our tests fail.
  */
 async function cleanUp() {
-  const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+  const { Services } = ChromeUtils.import(
+    "resource://gre/modules/Services.jsm"
+  );
 
-  let files = [
-    "places.sqlite",
-    "cookies.sqlite",
-    "signons.sqlite",
-  ];
+  let files = ["places.sqlite", "cookies.sqlite", "signons.sqlite"];
 
   for (let i = 0; i < files.length; i++) {
     let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
     file.append(files[i]);
-    if (file.exists())
+    if (file.exists()) {
       file.remove(false);
+    }
   }
 
   await new Promise(resolve => {
-    Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_PERMISSIONS, value => resolve());
+    Services.clearData.deleteData(
+      Ci.nsIClearDataService.CLEAR_PERMISSIONS,
+      value => resolve()
+    );
   });
 }
 cleanUp();
--- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
+++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
@@ -6,20 +6,25 @@
 
 /**
  * Test added with bug 460086 to test the behavior of the new API that was added
  * to remove all traces of visiting a site.
  */
 
 // Globals
 
-const {ForgetAboutSite} = ChromeUtils.import("resource://gre/modules/ForgetAboutSite.jsm");
+const { ForgetAboutSite } = ChromeUtils.import(
+  "resource://gre/modules/ForgetAboutSite.jsm"
+);
 
-ChromeUtils.defineModuleGetter(this, "PlacesTestUtils",
-                               "resource://testing-common/PlacesTestUtils.jsm");
+ChromeUtils.defineModuleGetter(
+  this,
+  "PlacesTestUtils",
+  "resource://testing-common/PlacesTestUtils.jsm"
+);
 
 const COOKIE_EXPIRY = Math.round(Date.now() / 1000) + 60;
 const COOKIE_NAME = "testcookie";
 const COOKIE_PATH = "/";
 
 const LOGIN_USERNAME = "username";
 const LOGIN_PASSWORD = "password";
 const LOGIN_USERNAME_FIELD = "username_field";
@@ -34,31 +39,44 @@ const PREFERENCE_NAME = "test-pref";
 
 /**
  * Add a cookie to the cookie service.
  *
  * @param aDomain
  */
 function add_cookie(aDomain) {
   check_cookie_exists(aDomain, false);
-  Services.cookies.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
-                       COOKIE_EXPIRY, {}, Ci.nsICookie.SAMESITE_NONE);
+  Services.cookies.add(
+    aDomain,
+    COOKIE_PATH,
+    COOKIE_NAME,
+    "",
+    false,
+    false,
+    false,
+    COOKIE_EXPIRY,
+    {},
+    Ci.nsICookie.SAMESITE_NONE
+  );
   check_cookie_exists(aDomain, true);
 }
 
 /**
  * Checks to ensure that a cookie exists or not for a domain.
  *
  * @param aDomain
  *        The domain to check for the cookie.
  * @param aExists
  *        True if the cookie should exist, false otherwise.
  */
 function check_cookie_exists(aDomain, aExists) {
-  Assert.equal(aExists, Services.cookies.cookieExists(aDomain, COOKIE_PATH, COOKIE_NAME, {}));
+  Assert.equal(
+    aExists,
+    Services.cookies.cookieExists(aDomain, COOKIE_PATH, COOKIE_NAME, {})
+  );
 }
 
 /**
  * Adds a disabled host to the login manager.
  *
  * @param aHost
  *        The host to add to the list of disabled hosts.
  */
@@ -83,20 +101,28 @@ function check_disabled_host(aHost, aIsD
 /**
  * Adds a login for the specified host to the login manager.
  *
  * @param aHost
  *        The host to add the login for.
  */
 function add_login(aHost) {
   check_login_exists(aHost, false);
-  let login = Cc["@mozilla.org/login-manager/loginInfo;1"].
-              createInstance(Ci.nsILoginInfo);
-  login.init(aHost, "", null, LOGIN_USERNAME, LOGIN_PASSWORD,
-             LOGIN_USERNAME_FIELD, LOGIN_PASSWORD_FIELD);
+  let login = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(
+    Ci.nsILoginInfo
+  );
+  login.init(
+    aHost,
+    "",
+    null,
+    LOGIN_USERNAME,
+    LOGIN_PASSWORD,
+    LOGIN_USERNAME_FIELD,
+    LOGIN_PASSWORD_FIELD
+  );
   Services.logins.addLogin(login);
   check_login_exists(aHost, true);
 }
 
 /**
  * Checks to see if a login exists for a host.
  *
  * @param aHost
@@ -112,67 +138,78 @@ function check_login_exists(aHost, aExis
 /**
  * Adds a permission for the specified URI to the permission manager.
  *
  * @param aURI
  *        The URI to add the test permission for.
  */
 function add_permission(aURI) {
   check_permission_exists(aURI, false);
-  let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
+  let principal = Services.scriptSecurityManager.createCodebasePrincipal(
+    aURI,
+    {}
+  );
 
   Services.perms.addFromPrincipal(principal, PERMISSION_TYPE, PERMISSION_VALUE);
   check_permission_exists(aURI, true);
 }
 
 /**
  * Checks to see if a permission exists for the given URI.
  *
  * @param aURI
  *        The URI to check if a permission exists.
  * @param aExists
  *        True if the permission should exist, false otherwise.
  */
 function check_permission_exists(aURI, aExists) {
-  let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
+  let principal = Services.scriptSecurityManager.createCodebasePrincipal(
+    aURI,
+    {}
+  );
 
-  let perm = Services.perms.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE);
+  let perm = Services.perms.testExactPermissionFromPrincipal(
+    principal,
+    PERMISSION_TYPE
+  );
   let checker = aExists ? "equal" : "notEqual";
   Assert[checker](perm, PERMISSION_VALUE);
 }
 
 /**
  * Adds a content preference for the specified URI.
  *
  * @param aURI
  *        The URI to add a preference for.
  */
 function add_preference(aURI) {
   return new Promise(resolve => {
-    let cp = Cc["@mozilla.org/content-pref/service;1"].
-               getService(Ci.nsIContentPrefService2);
+    let cp = Cc["@mozilla.org/content-pref/service;1"].getService(
+      Ci.nsIContentPrefService2
+    );
     cp.set(aURI.spec, PREFERENCE_NAME, "foo", null, {
       handleCompletion: () => resolve(),
     });
   });
 }
 
 /**
  * Checks to see if a content preference exists for the given URI.
  *
  * @param aURI
  *        The URI to check if a preference exists.
  */
 function preference_exists(aURI) {
   return new Promise(resolve => {
-    let cp = Cc["@mozilla.org/content-pref/service;1"].
-               getService(Ci.nsIContentPrefService2);
+    let cp = Cc["@mozilla.org/content-pref/service;1"].getService(
+      Ci.nsIContentPrefService2
+    );
     let exists = false;
     cp.getByDomainAndName(aURI.spec, PREFERENCE_NAME, null, {
-      handleResult: () => exists = true,
+      handleResult: () => (exists = true),
       handleCompletion: () => resolve(exists),
     });
   });
 }
 
 // Test Functions
 
 // History
@@ -333,66 +370,73 @@ async function test_content_preferences_
 
   // Reset state
   await ForgetAboutSite.removeDataFromDomain("ilovemozilla.org");
   Assert.equal(false, await preference_exists(TEST_URI));
 }
 
 function push_registration_exists(aURL, ps) {
   return new Promise(resolve => {
-    let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(aURL);
+    let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(
+      aURL
+    );
     return ps.getSubscription(aURL, principal, (status, record) => {
       if (!Components.isSuccessCode(status)) {
         resolve(false);
       } else {
         resolve(!!record);
       }
     });
   });
 }
 
 // Push
 async function test_push_cleared() {
   let ps;
   try {
-    ps = Cc["@mozilla.org/push/Service;1"].
-           getService(Ci.nsIPushService);
+    ps = Cc["@mozilla.org/push/Service;1"].getService(Ci.nsIPushService);
   } catch (e) {
     // No push service, skip test.
     return;
   }
 
   do_get_profile();
   setPrefs();
-  const {PushServiceWebSocket} = ChromeUtils.import("resource://gre/modules/PushServiceWebSocket.jsm");
-  const {PushService} = serviceExports;
+  const { PushServiceWebSocket } = ChromeUtils.import(
+    "resource://gre/modules/PushServiceWebSocket.jsm"
+  );
+  const { PushService } = serviceExports;
   const userAgentID = "bd744428-f125-436a-b6d0-dd0c9845837f";
   const channelID = "0ef2ad4a-6c49-41ad-af6e-95d2425276bf";
 
   let db = PushServiceWebSocket.newPushDB();
 
   try {
     PushService.init({
       serverURI: "wss://push.example.org/",
       db,
       makeWebSocket(uriObj) {
         return new MockWebSocket(uriObj, {
           onHello(request) {
-            this.serverSendMsg(JSON.stringify({
-              messageType: "hello",
-              status: 200,
-              uaid: userAgentID,
-            }));
+            this.serverSendMsg(
+              JSON.stringify({
+                messageType: "hello",
+                status: 200,
+                uaid: userAgentID,
+              })
+            );
           },
           onUnregister(request) {
-            this.serverSendMsg(JSON.stringify({
-              messageType: "unregister",
-              status: 200,
-              channelID: request.channelID,
-            }));
+            this.serverSendMsg(
+              JSON.stringify({
+                messageType: "unregister",
+                status: 200,
+                channelID: request.channelID,
+              })
+            );
           },
         });
       },
     });
 
     const TEST_URL = "https://www.mozilla.org/scope/";
     Assert.equal(false, await push_registration_exists(TEST_URL, ps));
     await db.put({
@@ -433,19 +477,27 @@ async function test_cache_cleared() {
   };
   Services.obs.addObserver(observer, "cacheservice:empty-cache");
   await ForgetAboutSite.removeDataFromDomain("mozilla.org");
   do_test_pending();
 }
 
 async function test_storage_cleared() {
   function getStorageForURI(aURI) {
-    let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
+    let principal = Services.scriptSecurityManager.createCodebasePrincipal(
+      aURI,
+      {}
+    );
 
-    return Services.domStorageManager.createStorage(null, principal, principal, "");
+    return Services.domStorageManager.createStorage(
+      null,
+      principal,
+      principal,
+      ""
+    );
   }
 
   Services.prefs.setBoolPref("dom.storage.client_validation", false);
 
   let s = [
     getStorageForURI(Services.io.newURI("http://mozilla.org")),
     getStorageForURI(Services.io.newURI("http://my.mozilla.org")),
     getStorageForURI(Services.io.newURI("http://ilovemozilla.org")),
@@ -504,13 +556,14 @@ var tests = [
   // Storage
   test_storage_cleared,
 
   // Cache
   test_cache_cleared,
 ];
 
 function run_test() {
-  for (let i = 0; i < tests.length; i++)
+  for (let i = 0; i < tests.length; i++) {
     add_task(tests[i]);
+  }
 
   run_next_test();
 }