Ticket #22084: 0002-PATCH-Bug-1372072-Part-2-Add-a-test-case-for-check-w.patch

File 0002-PATCH-Bug-1372072-Part-2-Add-a-test-case-for-check-w.patch, 2.8 KB (added by igt0, 20 months ago)

Version 2 - Backport test from firefox

  • browser/components/resistfingerprinting/test/browser/browser.ini

    From c01b2083af860c9158e182dec23e3c4b8995950b Mon Sep 17 00:00:00 2001
    From: Tim Huang <tihuang@mozilla.com>
    Date: Wed, 13 Dec 2017 15:35:50 -0200
    Subject: [PATCH 2/2] [PATCH] 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                | 34 ++++++++++++++++++++++
     2 files changed, 35 insertions(+)
     create mode 100644 browser/components/resistfingerprinting/test/browser/browser_netInfo.js
    
    diff --git a/browser/components/resistfingerprinting/test/browser/browser.ini b/browser/components/resistfingerprinting/test/browser/browser.ini
    index 4b81c91d8c6c..b596f437caa2 100644
    a b support-files = 
    44  file_dummy.html
    55  head.js
    66
     7[browser_netInfo.js]
    78[browser_roundedWindow_dialogWindow.js]
    89[browser_roundedWindow_newWindow.js]
    910[browser_roundedWindow_open_max.js]
  • new file rowser/components/resistfingerprinting/test/browser/browser_netInfo.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..e1b69dc151a5
    - +  
     1/**
     2 * Bug 1372072 - A test case for check whether network information API has been
     3 *   spoofed correctly when 'privacy.resistFingerprinting' is true;
     4 */
     5
     6const TEST_PATH = "http://example.net/browser/browser/" +
     7                  "components/resistfingerprinting/test/browser/"
     8
     9
     10async function testWindow() {
     11  // Open a tab to test network information in a content.
     12  let tab = await BrowserTestUtils.openNewForegroundTab(
     13    gBrowser, TEST_PATH + "file_dummy.html");
     14
     15  await ContentTask.spawn(tab.linkedBrowser, null, async function() {
     16    ok("connection" in content.navigator, "navigator.connection should exist");
     17
     18    is(content.navigator.connection.type, "unknown", "The connection type is spoofed correctly");
     19  });
     20
     21  await BrowserTestUtils.removeTab(tab);
     22}
     23
     24add_task(async function runTest() {
     25  await SpecialPowers.pushPrefEnv({"set":
     26    [
     27      ["privacy.resistFingerprinting", true],
     28      ["dom.netinfo.enabled",          true]
     29    ]
     30  });
     31
     32  await testWindow();
     33});
     34