[tbb-commits] [tor-browser/tor-browser-52.5.2esr-7.5-2] Bug 1372072 - Part 2: Add a test case for check whether network information API has been spoofed correctly when 'privacy.resistFingerprinting' is true. r=arthuredelstein, baku

gk at torproject.org gk at torproject.org
Thu Dec 14 12:12:25 UTC 2017


commit a72faadea544a71ae5ca95ec816f2684c205b56a
Author: Tim Huang <tihuang at mozilla.com>
Date:   Wed Dec 13 15:35:50 2017 -0200

    Bug 1372072 - Part 2: Add a test case for check whether network information API has been spoofed correctly when 'privacy.resistFingerprinting' is true. r=arthuredelstein,baku
    
    This adds a test case to test that network information is correctly spoofed when
    'privacy.resistFingerprinting' is true.
    
    Firefox ESR 52 does not have the navigation object inside workers. Thus, the
    worker test was removed.
    
    MozReview-Commit-ID: Lt6HZlFrcja
    
    --HG--
    extra : rebase_source : 70d44115532549814af9fce3af9fe379e36bca80
---
 .../resistfingerprinting/test/browser/browser.ini  |  1 +
 .../test/browser/browser_netInfo.js                | 32 ++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/browser/components/resistfingerprinting/test/browser/browser.ini b/browser/components/resistfingerprinting/test/browser/browser.ini
index 4b81c91d8c6c..b596f437caa2 100644
--- a/browser/components/resistfingerprinting/test/browser/browser.ini
+++ b/browser/components/resistfingerprinting/test/browser/browser.ini
@@ -4,6 +4,7 @@ support-files =
   file_dummy.html
   head.js
 
+[browser_netInfo.js]
 [browser_roundedWindow_dialogWindow.js]
 [browser_roundedWindow_newWindow.js]
 [browser_roundedWindow_open_max.js]
diff --git a/browser/components/resistfingerprinting/test/browser/browser_netInfo.js b/browser/components/resistfingerprinting/test/browser/browser_netInfo.js
new file mode 100644
index 000000000000..7c6114212ffd
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/browser/browser_netInfo.js
@@ -0,0 +1,32 @@
+/**
+ * Bug 1372072 - A test case for check whether network information API has been
+ *   spoofed correctly when 'privacy.resistFingerprinting' is true;
+ */
+
+const TEST_PATH = "http://example.net/browser/browser/" +
+                  "components/resistfingerprinting/test/browser/"
+
+async function testWindow() {
+  // Open a tab to test network information in a content.
+  let tab = await BrowserTestUtils.openNewForegroundTab(
+    gBrowser, TEST_PATH + "file_dummy.html");
+
+  await ContentTask.spawn(tab.linkedBrowser, null, async function() {
+    ok("connection" in content.navigator, "navigator.connection should exist");
+
+    is(content.navigator.connection.type, "unknown", "The connection type is spoofed correctly");
+  });
+
+  await BrowserTestUtils.removeTab(tab);
+}
+
+add_task(async function runTest() {
+  await SpecialPowers.pushPrefEnv({"set":
+    [
+      ["privacy.resistFingerprinting", true],
+      ["dom.netinfo.enabled",          true]
+    ]
+  });
+
+  await testWindow();
+});



More information about the tbb-commits mailing list