Bug 1330890 - Part 2: Add a test case for using UTC timezone when 'privacy.resistfingerprinting' is true. r=arthuredelstein,Ehsan
authorTim Huang <tihuang@mozilla.com>
Wed, 05 Apr 2017 16:05:29 +0800
changeset 391184 80144f502fb63d35755c1601f647637c31368765
parent 391183 0fedf8c86ceb3d306ab6f655012d22303e10993f
child 391185 d3261993daa1437b49fe72a806cecc4090f242ed
push id53
push userfmarier@mozilla.com
push dateMon, 15 May 2017 17:28:28 +0000
reviewersarthuredelstein, Ehsan
bugs1330890
milestone55.0a1
Bug 1330890 - Part 2: Add a test case for using UTC timezone when 'privacy.resistfingerprinting' is true. r=arthuredelstein,Ehsan Adding a test case for verifying the Date() object of javascript will use UTC timezone instead of the default one when fingerprinting resistance is enabled. MozReview-Commit-ID: 1Vavhb4HMs5
browser/components/resistfingerprinting/test/browser/browser.ini
browser/components/resistfingerprinting/test/browser/browser_timezone.js
--- a/browser/components/resistfingerprinting/test/browser/browser.ini
+++ b/browser/components/resistfingerprinting/test/browser/browser.ini
@@ -7,8 +7,9 @@ support-files =
 [browser_roundedWindow_dialogWindow.js]
 [browser_roundedWindow_newWindow.js]
 [browser_roundedWindow_open_max.js]
 [browser_roundedWindow_open_mid.js]
 [browser_roundedWindow_open_min.js]
 [browser_roundedWindow_windowSetting_max.js]
 [browser_roundedWindow_windowSetting_mid.js]
 [browser_roundedWindow_windowSetting_min.js]
+[browser_timezone.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/browser/browser_timezone.js
@@ -0,0 +1,38 @@
+/**
+ * Bug 1330890 - A test case for verifying Date() object of javascript will use
+ *               UTC timezone after fingerprinting resistance is enabled.
+ */
+
+const TEST_DOMAIN = "http://example.net/";
+const TEST_PATH = TEST_DOMAIN + "browser/browser/components/resistFingerprinting/test/browser/";
+
+add_task(function* setup() {
+  yield SpecialPowers.pushPrefEnv({"set":
+    [["privacy.resistFingerprinting", true]]
+  });
+});
+
+add_task(function* test_timezone() {
+  // Load a page and verify the timezone.
+  let tab = yield BrowserTestUtils.openNewForegroundTab(
+    gBrowser, TEST_PATH + "file_dummy.html");
+
+  yield ContentTask.spawn(tab.linkedBrowser, null,
+    function* () {
+      let dateObj = new Date();
+      let dateString = dateObj.toString();
+
+      ok(dateString.endsWith("(UTC)"), "The date string is in UTC timezone.");
+      is(dateObj.getFullYear(), dateObj.getUTCFullYear(),
+           "The full year reports in UTC timezone.");
+      is(dateObj.getMonth(), dateObj.getUTCMonth(), "The month reports in UTC timezone.");
+      is(dateObj.getDate(), dateObj.getUTCDate(), "The month reports in UTC timezone.");
+      is(dateObj.getDay(), dateObj.getUTCDay(), "The day reports in UTC timezone.");
+      is(dateObj.getHours(), dateObj.getUTCHours(), "The hours reports in UTC timezone.");
+      is(dateObj.getTimezoneOffset(), 0, "The difference with UTC timezone is 0.");
+
+    }
+  );
+
+  yield BrowserTestUtils.removeTab(tab);
+});