Bug 1483378 - Part 3: Add tests for the new Cookies and Site Data UI; r=johannh
☠☠ backed out by 89e493ded984 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 14 Aug 2018 18:27:01 -0400
changeset 487512 374d33355d31aea35b9312feee4218cb5cdedde4
parent 487511 26bc4e3382d47344027382a2c0951d000c442f41
child 487513 9c75236893debfe6aa69e04259a13944459cee34
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1483378
milestone63.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 1483378 - Part 3: Add tests for the new Cookies and Site Data UI; r=johannh These tests extend the existing tests for the old UI, and ensure the new states in the new UI work properly.
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_privacypane_1.js
browser/components/preferences/in-content/tests/browser_privacypane_2.js
browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -64,16 +64,17 @@ skip-if = e10s
 [browser_permissions_urlFieldHidden.js]
 [browser_proxy_backup.js]
 [browser_privacypane.js]
 run-if = nightly_build
 # browser_privacypane.js only has Browser Error collection tests currently,
 # which is disabled outside Nightly. Remove this once non-Nightly tests are
 # added.
 [browser_privacypane_1.js]
+[browser_privacypane_2.js]
 [browser_privacypane_3.js]
 [browser_privacypane_5.js]
 [browser_sanitizeOnShutdown_prefLocked.js]
 [browser_searchShowSuggestionsFirst.js]
 [browser_searchsuggestions.js]
 [browser_security-1.js]
 [browser_security-2.js]
 [browser_spotlight.js]
--- a/browser/components/preferences/in-content/tests/browser_privacypane_1.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_1.js
@@ -2,15 +2,19 @@ let rootDir = getRootDirectory(gTestPath
 let jar = getJar(rootDir);
 if (jar) {
   let tmpdir = extractJarToTmp(jar);
   rootDir = "file://" + tmpdir.path + "/";
 }
 /* import-globals-from privacypane_tests_perwindow.js */
 Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
 
+SpecialPowers.pushPrefEnv({"set":
+  [["browser.contentblocking.cookies-site-data.ui.enabled", false]]
+});
+
 run_test_subset([
   test_pane_visibility,
   test_dependent_elements,
   test_dependent_cookie_elements,
   test_dependent_clearonclose_elements,
   test_dependent_prefs,
 ]);
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_2.js
@@ -0,0 +1,20 @@
+let rootDir = getRootDirectory(gTestPath);
+let jar = getJar(rootDir);
+if (jar) {
+  let tmpdir = extractJarToTmp(jar);
+  rootDir = "file://" + tmpdir.path + "/";
+}
+/* import-globals-from privacypane_tests_perwindow.js */
+Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
+
+SpecialPowers.pushPrefEnv({"set":
+  [["browser.contentblocking.cookies-site-data.ui.enabled", true]]
+});
+
+run_test_subset([
+  test_pane_visibility,
+  test_dependent_elements,
+  test_dependent_cookie_elements,
+  test_dependent_clearonclose_elements,
+  test_dependent_prefs,
+]);
--- a/browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
+++ b/browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
@@ -49,17 +49,19 @@ function test_dependent_elements(win) {
     win.document.getElementById("keepUntil"),
     win.document.getElementById("keepCookiesUntil"),
     win.document.getElementById("alwaysClear"),
   ];
   controls.forEach(function(control) {
     ok(control, "the dependent controls should exist");
   });
   let independents = [
-    win.document.getElementById("acceptCookies"),
+    win.contentBlockingCookiesAndSiteDataUiEnabled ?
+      win.document.getElementById("blockCookies") :
+      win.document.getElementById("acceptCookies"),
     win.document.getElementById("acceptThirdPartyLabel"),
     win.document.getElementById("acceptThirdPartyMenu")
   ];
   independents.forEach(function(control) {
     ok(control, "the independent controls should exist");
   });
   let cookieexceptions = win.document.getElementById("cookieExceptions");
   ok(cookieexceptions, "the cookie exceptions button should exist");
@@ -115,47 +117,82 @@ function test_dependent_elements(win) {
   check_independents(false);
 }
 
 function test_dependent_cookie_elements(win) {
   let keepUntil = win.document.getElementById("keepUntil");
   let keepCookiesUntil = win.document.getElementById("keepCookiesUntil");
   let acceptThirdPartyLabel = win.document.getElementById("acceptThirdPartyLabel");
   let acceptThirdPartyMenu = win.document.getElementById("acceptThirdPartyMenu");
+  let blockCookiesLabel = win.document.getElementById("blockCookiesLabel");
+  let blockCookiesMenu = win.document.getElementById("blockCookiesMenu");
 
-  let controls = [acceptThirdPartyLabel, acceptThirdPartyMenu, keepUntil, keepCookiesUntil];
+  const newUI = win.contentBlockingCookiesAndSiteDataUiEnabled;
+  let controls = newUI ?
+    [blockCookiesLabel, blockCookiesMenu, keepUntil, keepCookiesUntil] :
+    [acceptThirdPartyLabel, acceptThirdPartyMenu, keepUntil, keepCookiesUntil];
   controls.forEach(function(control) {
     ok(control, "the dependent cookie controls should exist");
   });
-  let acceptcookies = win.document.getElementById("acceptCookies");
-  ok(acceptcookies, "the accept cookies checkbox should exist");
+  let acceptcookies, blockcookies;
+  if (newUI) {
+    blockcookies = win.document.getElementById("blockCookies");
+    ok(blockcookies, "the block cookies checkbox should exist");
+  } else {
+    acceptcookies = win.document.getElementById("acceptCookies");
+    ok(acceptcookies, "the accept cookies checkbox should exist");
+  }
 
   function expect_disabled(disabled, c = controls) {
     c.forEach(function(control) {
       is(control.disabled, disabled,
         control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled");
     });
   }
 
-  acceptcookies.value = "2";
-  controlChanged(acceptcookies);
-  expect_disabled(true);
+  if (newUI) {
+    blockcookies.value = "disallow";
+    controlChanged(blockcookies);
+    expect_disabled(false);
+
+    blockcookies.value = "allow";
+    controlChanged(blockcookies);
+    expect_disabled(true, [blockCookiesLabel, blockCookiesMenu]);
+    expect_disabled(false, [keepUntil, keepCookiesUntil]);
 
-  acceptcookies.value = "1";
-  controlChanged(acceptcookies);
-  expect_disabled(false);
+    blockCookiesMenu.value = "always";
+    controlChanged(blockCookiesMenu);
+    expect_disabled(true, [keepUntil, keepCookiesUntil]);
+    expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]);
+
+    blockCookiesMenu.value = "trackers";
+    controlChanged(blockCookiesMenu);
+    expect_disabled(false);
+  } else {
+    acceptcookies.value = "2";
+    controlChanged(acceptcookies);
+    expect_disabled(true);
+
+    acceptcookies.value = "1";
+    controlChanged(acceptcookies);
+    expect_disabled(false);
+  }
 
   let historymode = win.document.getElementById("historyMode");
 
   // The History mode setting for "never remember history" should still
   // disable the "keep cookies until..." menu.
   historymode.value = "dontremember";
   controlChanged(historymode);
   expect_disabled(true, [keepUntil, keepCookiesUntil]);
-  expect_disabled(false, [acceptThirdPartyLabel, acceptThirdPartyMenu]);
+  if (newUI) {
+    expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]);
+  } else {
+    expect_disabled(false, [acceptThirdPartyLabel, acceptThirdPartyMenu]);
+  }
 
   historymode.value = "remember";
   controlChanged(historymode);
   expect_disabled(false);
 }
 
 function test_dependent_clearonclose_elements(win) {
   let historymode = win.document.getElementById("historyMode");