[Pkg-mozext-commits] [requestpolicy] 17/65: [imp] settings to disable speculative pre-connections

David Prévot taffit at moszumanska.debian.org
Fri Mar 25 22:59:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 7244262fa7486557cfac68a66b709ffa4b6500d4
Author: Martin Kimmerle <dev at 256k.de>
Date:   Wed Jan 13 12:35:55 2016 +0100

    [imp] settings to disable speculative pre-connections
    
    Resolves #628
---
 src/content/lib/default-preferences.js             |  2 +
 src/content/main/pref-manager.jsm                  | 17 +++++++-
 src/content/models/prefs.jsm                       |  3 ++
 src/content/settings/advancedprefs.html            | 26 +++++++++++
 src/content/settings/advancedprefs.js              | 35 +++++++++++++++
 src/locale/de/requestpolicy.properties             |  1 +
 src/locale/en-US/requestpolicy.properties          |  1 +
 src/locale/eo/requestpolicy.properties             |  1 +
 src/locale/es-MX/requestpolicy.properties          |  1 +
 src/locale/eu/requestpolicy.properties             |  1 +
 src/locale/fr/requestpolicy.properties             |  1 +
 src/locale/it/requestpolicy.properties             |  1 +
 src/locale/ja/requestpolicy.properties             |  1 +
 src/locale/ko-KR/requestpolicy.properties          |  1 +
 src/locale/lv-LV/requestpolicy.properties          |  1 +
 src/locale/nl/requestpolicy.properties             |  1 +
 src/locale/pt-BR/requestpolicy.properties          |  1 +
 src/locale/ru-RU/requestpolicy.properties          |  1 +
 src/locale/sk-SK/requestpolicy.properties          |  1 +
 src/locale/sv-SE/requestpolicy.properties          |  1 +
 src/locale/tr/requestpolicy.properties             |  1 +
 src/locale/uk-UA/requestpolicy.properties          |  1 +
 src/locale/zh-CN/requestpolicy.properties          |  1 +
 src/locale/zh-TW/requestpolicy.properties          |  1 +
 tests/marionette/tests/settings/test_checkboxes.py | 51 ++++++++++++++++------
 25 files changed, 139 insertions(+), 14 deletions(-)

diff --git a/src/content/lib/default-preferences.js b/src/content/lib/default-preferences.js
index d573e37..c03b99d 100644
--- a/src/content/lib/default-preferences.js
+++ b/src/content/lib/default-preferences.js
@@ -20,6 +20,8 @@ pref("extensions.requestpolicy.prefetch.link.disableOnStartup", true);
 pref("extensions.requestpolicy.prefetch.link.restoreDefaultOnUninstall", true);
 pref("extensions.requestpolicy.prefetch.dns.disableOnStartup", true);
 pref("extensions.requestpolicy.prefetch.dns.restoreDefaultOnUninstall", true);
+pref("extensions.requestpolicy.prefetch.preconnections.disableOnStartup", true);
+pref("extensions.requestpolicy.prefetch.preconnections.restoreDefaultOnUninstall", true);
 
 pref("extensions.requestpolicy.contextMenu", true);
 pref("extensions.requestpolicy.menu.sorting", "numRequests");
diff --git a/src/content/main/pref-manager.jsm b/src/content/main/pref-manager.jsm
index 22fd414..3e2d88f 100644
--- a/src/content/main/pref-manager.jsm
+++ b/src/content/main/pref-manager.jsm
@@ -50,6 +50,8 @@ var PrefManager = (function() {
     var resetLinkPrefetch = Prefs.get("prefetch.link." +
                                       "restoreDefaultOnUninstall");
     var resetDNSPrefetch = Prefs.get("prefetch.dns.restoreDefaultOnUninstall");
+    var resetPreConnections = Prefs.get("prefetch.preconnections." +
+                                        "restoreDefaultOnUninstall");
 
     if (resetLinkPrefetch) {
       if (Prefs.isSet("root/ network.prefetch-next")) {
@@ -61,6 +63,11 @@ var PrefManager = (function() {
         Prefs.reset("root/ network.dns.disablePrefetch");
       }
     }
+    if (resetPreConnections) {
+      if (Prefs.isSet("root/ network.http.speculative-parallel-limit")) {
+        Prefs.reset("root/ network.http.speculative-parallel-limit");
+      }
+    }
     Services.prefs.savePrefFile(null);
   }
 
@@ -84,7 +91,7 @@ var PrefManager = (function() {
     /* jshint +W126 */
 
     // ================================
-    // Link/DNS prefetching
+    // prefetching
     // --------------------
     // Disable link prefetch.
     if (Prefs.get("prefetch.link.disableOnStartup")) {
@@ -104,6 +111,14 @@ var PrefManager = (function() {
         console.info("Disabled DNS prefetch.");
       }
     }
+    // Disable Speculative pre-connections.
+    if (Prefs.get("prefetch.preconnections.disableOnStartup")) {
+      if (!Prefs.isSet("root/ network.http.speculative-parallel-limit") ||
+          Prefs.get("root/ network.http.speculative-parallel-limit" !== 0)) {
+        Prefs.set("root/ network.http.speculative-parallel-limit", 0);
+        console.info("Disabled Speculative pre-connections.");
+      }
+    }
 
     // ================================
     // Clean up old, unused prefs (removed in 0.2.0).
diff --git a/src/content/models/prefs.jsm b/src/content/models/prefs.jsm
index 7e2be58..690aff4 100644
--- a/src/content/models/prefs.jsm
+++ b/src/content/models/prefs.jsm
@@ -66,6 +66,8 @@ var Prefs = (function() {
       "prefetch.dns.restoreDefaultOnUninstall": "BoolPref",
       "prefetch.link.disableOnStartup": "BoolPref",
       "prefetch.link.restoreDefaultOnUninstall": "BoolPref",
+      "prefetch.preconnections.disableOnStartup": "BoolPref",
+      "prefetch.preconnections.restoreDefaultOnUninstall": "BoolPref",
       "privateBrowsingPermanentWhitelisting": "BoolPref",
       "startWithAllowAllEnabled": "BoolPref",
       "welcomeWindowShown": "BoolPref",
@@ -76,6 +78,7 @@ var Prefs = (function() {
 
     root: new PrefBranch("", {
       "network.dns.disablePrefetch": "BoolPref",
+      "network.http.speculative-parallel-limit": "IntPref",
       "network.prefetch-next": "BoolPref",
     })
   };
diff --git a/src/content/settings/advancedprefs.html b/src/content/settings/advancedprefs.html
index 0a464a2..9fefe44 100644
--- a/src/content/settings/advancedprefs.html
+++ b/src/content/settings/advancedprefs.html
@@ -96,6 +96,32 @@
               </div>
             </td>
           </tr>
+          <tr>
+            <td data-string="speculativePreConnections"></td>
+            <td>
+              <div>
+                <label>
+                  <input type="checkbox"
+                         id="pref-speculativePreConnections"/>
+                  <span data-string="enabled"></span>
+                </label>
+              </div>
+              <div>
+                <label>
+                  <input type="checkbox"
+                         id="pref-prefetch.preconnections.disableOnStartup"/>
+                  <span data-string="disableOnStartup"></span>
+                </label>
+              </div>
+              <div>
+                <label>
+                  <input type="checkbox"
+                         id="pref-prefetch.preconnections.restoreDefaultOnUninstall"/>
+                  <span data-string="restoreDefaultOnUninstall"></span>
+                </label>
+              </div>
+            </td>
+          </tr>
         </table>
 
         <div id="page-subsection" data-string="menuPreferences"></div>
diff --git a/src/content/settings/advancedprefs.js b/src/content/settings/advancedprefs.js
index 7457d30..6ba4b93 100644
--- a/src/content/settings/advancedprefs.js
+++ b/src/content/settings/advancedprefs.js
@@ -18,6 +18,7 @@
     "advancedPreferences",
     "linkPrefetching",
     "dnsPrefetching",
+    "speculativePreConnections",
     "enabled",
     "disableOnStartup",
     "restoreDefaultOnUninstall",
@@ -57,6 +58,16 @@
     $id("pref-prefetch.dns.restoreDefaultOnUninstall").checked =
         Prefs.get("prefetch.dns.restoreDefaultOnUninstall");
 
+    // Speculative pre-connections.
+    $id("pref-speculativePreConnections").checked =
+        Prefs.get("root/ network.http.speculative-parallel-limit") !== 0;
+
+    $id("pref-prefetch.preconnections.disableOnStartup").checked =
+        Prefs.get("prefetch.preconnections.disableOnStartup");
+
+    $id("pref-prefetch.preconnections.restoreDefaultOnUninstall").checked =
+        Prefs.get("prefetch.preconnections.restoreDefaultOnUninstall");
+
     // TODO: Create a class which acts as an API for preferences and which ensures
     // that the returned value is always a valid value for "string" preferences.
     var sorting = Prefs.get("menu.sorting");
@@ -127,6 +138,29 @@
           Services.prefs.savePrefFile(null);
         });
 
+    // Speculative pre-connections.
+    elManager.addListener($id("pref-speculativePreConnections"), "change", function(event) {
+      Prefs.set("root/ network.http.speculative-parallel-limit",
+          event.target.checked ? 6 : 0);
+      Services.prefs.savePrefFile(null);
+    });
+
+    elManager.addListener(
+        $id("pref-prefetch.preconnections.disableOnStartup"), "change",
+        function(event) {
+          Prefs.set("prefetch.preconnections.disableOnStartup",
+              event.target.checked);
+          Services.prefs.savePrefFile(null);
+        });
+
+    elManager.addListener(
+        $id("pref-prefetch.preconnections.restoreDefaultOnUninstall"), "change",
+        function(event) {
+          Prefs.set("prefetch.preconnections.restoreDefaultOnUninstall",
+              event.target.checked);
+          Services.prefs.savePrefFile(null);
+        });
+
     var sortingListener = function(event) {
       Prefs.set("menu.sorting", event.target.value);
       Services.prefs.savePrefFile(null);
@@ -148,6 +182,7 @@
       "",
       "root/ network.prefetch-next",
       "root/ network.dns.disablePrefetch",
+      "root/ network.http.speculative-parallel-limit",
     ], updateDisplay);
   };
 
diff --git a/src/locale/de/requestpolicy.properties b/src/locale/de/requestpolicy.properties
index 2d87c1f..8cad67c 100644
--- a/src/locale/de/requestpolicy.properties
+++ b/src/locale/de/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Dauerhaftes Erlauben im Privaten Modus ermögl
 advancedPreferences=Erweiterte Einstellungen
 linkPrefetching=Link Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Aktivieren
 disableOnStartup=Beim Start von Firefox deaktivieren
 restoreDefaultOnUninstall=Bei der Deinstallation von RequestPolicy Standardeinstellung wiederherstellen
diff --git a/src/locale/en-US/requestpolicy.properties b/src/locale/en-US/requestpolicy.properties
index 7d158b9..adf7d98 100644
--- a/src/locale/en-US/requestpolicy.properties
+++ b/src/locale/en-US/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Allow adding non-temporary rules when using Pr
 advancedPreferences=Advanced Preferences
 linkPrefetching=Link Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Enabled
 disableOnStartup=Disable on startup
 restoreDefaultOnUninstall=Restore default when RequestPolicy is uninstalled
diff --git a/src/locale/eo/requestpolicy.properties b/src/locale/eo/requestpolicy.properties
index b8e6157..8d7e2f0 100644
--- a/src/locale/eo/requestpolicy.properties
+++ b/src/locale/eo/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Ebligi neprovizoran permesadon dum Privata ret
 advancedPreferences=Advanced Preferences
 linkPrefetching=Laŭligila antaŭakirado
 dnsPrefetching=DNSa antaŭakirado
+speculativePreConnections=Speculative pre-connections
 enabled=Ŝaltita
 disableOnStartup=Malŝalti ĉe starto de la programo
 restoreDefaultOnUninstall=Restarigi la defaŭltan agordon ĉe malinstalo de RequestPolicy
diff --git a/src/locale/es-MX/requestpolicy.properties b/src/locale/es-MX/requestpolicy.properties
index c61d8a7..231e33c 100644
--- a/src/locale/es-MX/requestpolicy.properties
+++ b/src/locale/es-MX/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Al usar navegación privada permitir poner sit
 advancedPreferences=Advanced Preferences
 linkPrefetching=Descarga anticipada de enlaces
 dnsPrefetching=Descarga anticipada de DNS
+speculativePreConnections=Speculative pre-connections
 enabled=Activado
 disableOnStartup=Deshabilitar al inicio
 restoreDefaultOnUninstall=Restaurar predeterminados cuando RequestPolicy es des-instalado
diff --git a/src/locale/eu/requestpolicy.properties b/src/locale/eu/requestpolicy.properties
index addaa7b..b3675c5 100644
--- a/src/locale/eu/requestpolicy.properties
+++ b/src/locale/eu/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Baimendu aldi osorako zerrenda zuria Nabigatze
 advancedPreferences=Hobespen aurreratuak
 linkPrefetching=Lotura Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Gaituta
 disableOnStartup=Ezgaitu abioan
 restoreDefaultOnUninstall=Leheneratu lehenetsia RequestPolicy desinstalatzerakoan
diff --git a/src/locale/fr/requestpolicy.properties b/src/locale/fr/requestpolicy.properties
index dff262a..9355b44 100644
--- a/src/locale/fr/requestpolicy.properties
+++ b/src/locale/fr/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Autoriser la mise permanente en liste blanche
 advancedPreferences=Préférences avancées
 linkPrefetching=Préchargement des liens
 dnsPrefetching=Préchargement DNS
+speculativePreConnections=Speculative pre-connections
 enabled=Activé
 disableOnStartup=Désactiver au démarrage
 restoreDefaultOnUninstall=Rétablir les paramètres par défaut lorsque RequestPolicy est désinstallé
diff --git a/src/locale/it/requestpolicy.properties b/src/locale/it/requestpolicy.properties
index 13a6b5a..2eda5b3 100644
--- a/src/locale/it/requestpolicy.properties
+++ b/src/locale/it/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Permetti l'aggiunta di regole permanenti quand
 advancedPreferences=Preferenze Avanzate
 linkPrefetching=Prefetching dei Link
 dnsPrefetching=Prefetching DNS
+speculativePreConnections=Speculative pre-connections
 enabled=Abilitato
 disableOnStartup=Disabilita all'avvio
 restoreDefaultOnUninstall=Ripristina i predefiniti quando RequestPolicy viene disinstallato
diff --git a/src/locale/ja/requestpolicy.properties b/src/locale/ja/requestpolicy.properties
index 8295266..dcffda5 100644
--- a/src/locale/ja/requestpolicy.properties
+++ b/src/locale/ja/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=プライベートブラウジング中に恒
 advancedPreferences=上級者向け設定
 linkPrefetching=リンクの先読み
 dnsPrefetching=DNS の先読み
+speculativePreConnections=Speculative pre-connections
 enabled=有効にする
 disableOnStartup=起動時に無効にする
 restoreDefaultOnUninstall=RequestPolicy が削除されたとき、既定の設定に戻す
diff --git a/src/locale/ko-KR/requestpolicy.properties b/src/locale/ko-KR/requestpolicy.properties
index 9a66c91..f734ddd 100644
--- a/src/locale/ko-KR/requestpolicy.properties
+++ b/src/locale/ko-KR/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Allow adding non-temporary rules when using Pr
 advancedPreferences=Advanced Preferences
 linkPrefetching=Link Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Enabled
 disableOnStartup=Disable on startup
 restoreDefaultOnUninstall=Restore default when RequestPolicy is uninstalled
diff --git a/src/locale/lv-LV/requestpolicy.properties b/src/locale/lv-LV/requestpolicy.properties
index 93bc1fd..dc92aba 100644
--- a/src/locale/lv-LV/requestpolicy.properties
+++ b/src/locale/lv-LV/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Atļaut paliekošas izmaiņas baltajā sarakst
 advancedPreferences=Papildus iestatījumi
 linkPrefetching=Saišu priekšnese
 dnsPrefetching=Domēna vārdu (DNS) priekšnese
+speculativePreConnections=Speculative pre-connections
 enabled=Aktivizēts
 disableOnStartup=Atspējot pēc pārlūka iedarbināšanas
 restoreDefaultOnUninstall=Atjaunot noklusētās vērtības pēc RequestPolicy atinstalēšanas
diff --git a/src/locale/nl/requestpolicy.properties b/src/locale/nl/requestpolicy.properties
index a8e0c2b..5a0e22b 100644
--- a/src/locale/nl/requestpolicy.properties
+++ b/src/locale/nl/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Permanente witte lijst toestaan bij gebruik Pr
 advancedPreferences=Advanced Preferences
 linkPrefetching=Vooraf ophalen koppelingen
 dnsPrefetching=Vooraf ophalen DNS
+speculativePreConnections=Speculative pre-connections
 enabled=Ingeschakeld
 disableOnStartup=Uitschakelen bij opstarten
 restoreDefaultOnUninstall=Standaard herstellen wanneer RequestPolicy is gedeïnstalleerd
diff --git a/src/locale/pt-BR/requestpolicy.properties b/src/locale/pt-BR/requestpolicy.properties
index d2949f6..96d173a 100644
--- a/src/locale/pt-BR/requestpolicy.properties
+++ b/src/locale/pt-BR/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Adicionar permissões às listas também duran
 advancedPreferences=Advanced Preferences
 linkPrefetching=Pré-carregamento de links
 dnsPrefetching=Pré-busca de nomes de domínio (DNS)
+speculativePreConnections=Speculative pre-connections
 enabled=Ativo
 disableOnStartup=Desativado ao iniciar o navegador
 restoreDefaultOnUninstall=Restaurar padrão quando RequestPolicy for desinstalado
diff --git a/src/locale/ru-RU/requestpolicy.properties b/src/locale/ru-RU/requestpolicy.properties
index decd4cf..d0febb1 100644
--- a/src/locale/ru-RU/requestpolicy.properties
+++ b/src/locale/ru-RU/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Всегда использовать белы
 advancedPreferences=Advanced Preferences
 linkPrefetching=Предварительная загрузка ссылок
 dnsPrefetching=Упреждающее чтение DNS
+speculativePreConnections=Speculative pre-connections
 enabled=Включено
 disableOnStartup=Отключать при запуске
 restoreDefaultOnUninstall=Восстанавливать по умолчанию при удалении RequestPolicy
diff --git a/src/locale/sk-SK/requestpolicy.properties b/src/locale/sk-SK/requestpolicy.properties
index 29594a2..605b50e 100644
--- a/src/locale/sk-SK/requestpolicy.properties
+++ b/src/locale/sk-SK/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Povoliť trvalé whitelisting pri používaní
 advancedPreferences=Advanced Preferences
 linkPrefetching=Link Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Zapnuté
 disableOnStartup=Vypnúť pri spustení
 restoreDefaultOnUninstall=Obnoviť pôvodné pri odinštalovaní RequestPolicy
diff --git a/src/locale/sv-SE/requestpolicy.properties b/src/locale/sv-SE/requestpolicy.properties
index 9207871..e45917a 100644
--- a/src/locale/sv-SE/requestpolicy.properties
+++ b/src/locale/sv-SE/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Tillåt permanent vitlistning när privat surf
 advancedPreferences=Advanced Preferences
 linkPrefetching=Länkförhämtning
 dnsPrefetching=DNS-förhämtning
+speculativePreConnections=Speculative pre-connections
 enabled=Aktiverad
 disableOnStartup=Inaktivera vid start
 restoreDefaultOnUninstall=Återställ standard när RequestPolicy avinstalleras
diff --git a/src/locale/tr/requestpolicy.properties b/src/locale/tr/requestpolicy.properties
index cc7511f..deca9e3 100644
--- a/src/locale/tr/requestpolicy.properties
+++ b/src/locale/tr/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Özel Gezinti yaparken kalıcı beyazlisteleme
 advancedPreferences=Advanced Preferences
 linkPrefetching=Link Hafızalama
 dnsPrefetching=DNS Hafızalama
+speculativePreConnections=Speculative pre-connections
 enabled=Aktifleştirildi
 disableOnStartup=Başlangıçta etkisizleştir
 restoreDefaultOnUninstall=RequestPolicy silindiğinde herşeyi eski haline getir
diff --git a/src/locale/uk-UA/requestpolicy.properties b/src/locale/uk-UA/requestpolicy.properties
index 441eb8d..d0dee32 100644
--- a/src/locale/uk-UA/requestpolicy.properties
+++ b/src/locale/uk-UA/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=Allow adding non-temporary rules when using Pr
 advancedPreferences=Advanced Preferences
 linkPrefetching=Link Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Enabled
 disableOnStartup=Disable on startup
 restoreDefaultOnUninstall=Restore default when RequestPolicy is uninstalled
diff --git a/src/locale/zh-CN/requestpolicy.properties b/src/locale/zh-CN/requestpolicy.properties
index bee913e..2534860 100644
--- a/src/locale/zh-CN/requestpolicy.properties
+++ b/src/locale/zh-CN/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=允许在使用隐私浏览模式时添加永
 advancedPreferences=高级设置
 linkPrefetching=链接预取
 dnsPrefetching=DNS 预取
+speculativePreConnections=Speculative pre-connections
 enabled=启用
 disableOnStartup=在启动时禁用
 restoreDefaultOnUninstall=RequestPolicy 卸载时恢复默认
diff --git a/src/locale/zh-TW/requestpolicy.properties b/src/locale/zh-TW/requestpolicy.properties
index 166b8d7..3552645 100644
--- a/src/locale/zh-TW/requestpolicy.properties
+++ b/src/locale/zh-TW/requestpolicy.properties
@@ -47,6 +47,7 @@ allowAddingNonTemporaryRulesInPBM=私密瀏覽時允許永久性的白名單
 advancedPreferences=Advanced Preferences
 linkPrefetching=Link Prefetching
 dnsPrefetching=DNS Prefetching
+speculativePreConnections=Speculative pre-connections
 enabled=Enabled
 disableOnStartup=Disable on startup
 restoreDefaultOnUninstall=Restore default when RequestPolicy is uninstalled
diff --git a/tests/marionette/tests/settings/test_checkboxes.py b/tests/marionette/tests/settings/test_checkboxes.py
index 49ac6d1..d88b813 100644
--- a/tests/marionette/tests/settings/test_checkboxes.py
+++ b/tests/marionette/tests/settings/test_checkboxes.py
@@ -49,6 +49,13 @@ class TestCheckboxes(RequestPolicyTestCase):
         self._test("pref-prefetch.dns.restoreDefaultOnUninstall",
                    RP_BRANCH + "prefetch.dns.restoreDefaultOnUninstall")
 
+        self._test("pref-speculativePreConnections",
+                   self._preconnect_pref("network.http.speculative-parallel-limit"))
+        self._test("pref-prefetch.preconnections.disableOnStartup",
+                   RP_BRANCH + "prefetch.preconnections.disableOnStartup")
+        self._test("pref-prefetch.preconnections.restoreDefaultOnUninstall",
+                   RP_BRANCH + "prefetch.preconnections.restoreDefaultOnUninstall")
+
         self._test("menu.info.showNumRequests",
                    RP_BRANCH + "menu.info.showNumRequests")
 
@@ -64,13 +71,15 @@ class TestCheckboxes(RequestPolicyTestCase):
     # Private Helper Methods #
     ##########################
 
-    def _test(self, checkbox_id, pref_name, inverse=False):
+    def _test(self, checkbox_id, pref, inverse=False):
+        if isinstance(pref, str):
+            pref = self._pref(pref)
+
         with self.marionette.using_context("content"):
             checkbox = self.marionette.find_element("id", checkbox_id)
-            compare = partial(self._compare, checkbox, pref_name,
-                              inverse=inverse)
+            compare = partial(self._compare, checkbox, pref, inverse=inverse)
 
-            initial_value = self.prefs.get_pref(pref_name)
+            initial_value = pref["get"]()
 
             compare(initial_value)
             checkbox.click()
@@ -78,14 +87,14 @@ class TestCheckboxes(RequestPolicyTestCase):
             checkbox.click()
             compare(initial_value)
 
-            self._toggle_pref(pref_name)
+            self._toggle_pref(pref)
             compare(not initial_value)
-            self._toggle_pref(pref_name)
+            self._toggle_pref(pref)
             compare(initial_value)
 
-    def _compare(self, checkbox, pref_name, expected_pref_value, inverse=False):
+    def _compare(self, checkbox, pref, expected_pref_value, inverse=False):
         cb_value = checkbox.get_attribute("checked") == "true"
-        pref_value = self.prefs.get_pref(pref_name)
+        pref_value = pref["get"]()
 
         try:
             self.assertIsInstance(cb_value, bool)
@@ -99,10 +108,26 @@ class TestCheckboxes(RequestPolicyTestCase):
                 self.assertNotEqual(cb_value, pref_value)
         except:
             print ("pref name: {}, checkbox: {}, pref: {}"
-                   .format(pref_name, str(cb_value), str(pref_value)))
+                   .format(pref["name"], str(cb_value), str(pref_value)))
             raise
 
-    def _toggle_pref(self, pref_name):
-        current_value = self.prefs.get_pref(pref_name)
-        self.prefs.set_pref(pref_name, not current_value)
-
+    def _toggle_pref(self, pref):
+        current_value = pref["get"]()
+        pref["set"](not current_value)
+
+    def _pref(self, pref_name):
+        return {
+            "name": pref_name,
+            "get": lambda: self.prefs.get_pref(pref_name),
+            "set": lambda v: self.prefs.set_pref(pref_name, v)
+        }
+
+    def _preconnect_pref(self, pref_name):
+        def value():
+            return self.prefs.get_pref(pref_name)
+        return {
+            "name": pref_name,
+            "get": lambda: False if value() == 0 else True,
+            "set": lambda v: self.prefs.set_pref(pref_name,
+                                                 0 if v == False else 6)
+        }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list