[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-88.0.1-10.5-1] Bug 12620: TorBrowser regression tests



commit b8951393b6514a93dc01099dde96ab1ea01da40d
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date:   Wed Aug 27 16:25:00 2014 -0700

    Bug 12620: TorBrowser regression tests
    
    Regression tests for Bug #2950: Make Permissions Manager memory-only
    
    Regression tests for TB4: Tor Browser's Firefox preference overrides.
    
    Note: many more functional tests could be made here
    
    Regression tests for #2874: Block Components.interfaces from content
    
    Bug 18923: Add a script to run all Tor Browser specific tests
    
    Regression tests for Bug #16441: Suppress "Reset Tor Browser" prompt.
---
 run-tbb-tests                    | 66 +++++++++++++++++++++++++++++++++++
 tbb-tests-ignore.txt             | 13 +++++++
 tbb-tests/browser.ini            |  5 +++
 tbb-tests/browser_tor_TB4.js     | 35 +++++++++++++++++++
 tbb-tests/browser_tor_bug2950.js | 74 ++++++++++++++++++++++++++++++++++++++++
 tbb-tests/mochitest.ini          |  3 ++
 tbb-tests/moz.build              |  9 +++++
 tbb-tests/test_tor_bug2874.html  | 25 ++++++++++++++
 toolkit/toolkit.mozbuild         |  3 +-
 9 files changed, 232 insertions(+), 1 deletion(-)

diff --git a/run-tbb-tests b/run-tbb-tests
new file mode 100755
index 000000000000..bc09839f9f05
--- /dev/null
+++ b/run-tbb-tests
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# This script runs all the Mochitest tests that have been added or
+# modified since the last ffxbld commit.
+#
+# It does not currently run XPCShell tests. We should change this if we
+# start using this type or other types of tests.
+#
+# The logs of the tests are stored in the tbb-tests.log file.
+# Ignored tests are listed in the tbb-tests-ignore.txt file.
+#
+# https://trac.torproject.org/projects/tor/ticket/18923
+
+IFS=$'\n'
+
+if [ -n "$USE_TESTS_LIST" ] && [ -f tbb-tests-list.txt ]
+then
+    echo "Using tests list from file tbb-tests-list.txt"
+    tests=($(cat tbb-tests-list.txt))
+else
+    ffxbld_commit=$(git log -500 --format='oneline' | grep "TB3: Tor Browser's official .mozconfigs." \
+                                        | head -1 | cut -d ' ' -f 1)
+
+    tests=($(git diff --name-status "$ffxbld_commit" HEAD | \
+        grep -e '^[AM].*/test_[^/]\+\.\(html\|xul\)$' \
+             -e '^[AM].*/browser_[^/]\+\.js$' \
+             | sed 's/^[AM]\s\+//'))
+fi
+
+echo 'The following tests will be run:'
+for i in "${!tests[@]}"
+do
+    if [ -z "$USE_TESTS_LIST" ] \
+        && grep -q "^${tests[$i]}$" tbb-tests-ignore.txt
+    then
+        unset "tests[$i]"
+        continue
+    fi
+    echo "- ${tests[$i]}"
+done
+
+if [ -n "$WRITE_TESTS_LIST" ]
+then
+    rm -f tbb-tests-list.txt
+    for i in "${!tests[@]}"
+    do
+        echo "${tests[$i]}" >> tbb-tests-list.txt
+    done
+    exit 0
+fi
+
+rm -f tbb-tests.log
+echo $'\n''Starting tests'
+# We need `security.nocertdb = false` because of #18087. That pref is
+# forced to have the same value as `browser.privatebrowsing.autostart` in
+# torbutton, so we just set `browser.privatebrowsing.autostart=false` here.
+./mach mochitest --log-tbpl tbb-tests.log \
+    --setpref network.file.path_blacklist='' \
+    --setpref extensions.torbutton.use_nontor_proxy=true \
+    --setpref browser.privatebrowsing.autostart=false \
+                 "${tests[@]}"
+
+echo "*************************"
+echo "*************************"
+echo "Summary of failed tests:"
+grep --color=never TEST-UNEXPECTED-FAIL tbb-tests.log
diff --git a/tbb-tests-ignore.txt b/tbb-tests-ignore.txt
new file mode 100644
index 000000000000..ee3927a9e7c4
--- /dev/null
+++ b/tbb-tests-ignore.txt
@@ -0,0 +1,13 @@
+browser/extensions/onboarding/test/browser/browser_onboarding_accessibility.js
+browser/extensions/onboarding/test/browser/browser_onboarding_keyboard.js
+browser/extensions/onboarding/test/browser/browser_onboarding_notification.js
+browser/extensions/onboarding/test/browser/browser_onboarding_notification_2.js
+browser/extensions/onboarding/test/browser/browser_onboarding_notification_3.js
+browser/extensions/onboarding/test/browser/browser_onboarding_notification_4.js
+browser/extensions/onboarding/test/browser/browser_onboarding_notification_5.js
+browser/extensions/onboarding/test/browser/browser_onboarding_notification_click_auto_complete_tour.js
+browser/extensions/onboarding/test/browser/browser_onboarding_select_default_tour.js
+browser/extensions/onboarding/test/browser/browser_onboarding_skip_tour.js
+browser/extensions/onboarding/test/browser/browser_onboarding_tours.js
+browser/extensions/onboarding/test/browser/browser_onboarding_tourset.js
+browser/extensions/onboarding/test/browser/browser_onboarding_uitour.js
diff --git a/tbb-tests/browser.ini b/tbb-tests/browser.ini
new file mode 100644
index 000000000000..f481660f1417
--- /dev/null
+++ b/tbb-tests/browser.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+
+[browser_tor_bug2950.js]
+[browser_tor_omnibox.js]
+[browser_tor_TB4.js]
diff --git a/tbb-tests/browser_tor_TB4.js b/tbb-tests/browser_tor_TB4.js
new file mode 100644
index 000000000000..8bb12f360e5e
--- /dev/null
+++ b/tbb-tests/browser_tor_TB4.js
@@ -0,0 +1,35 @@
+// # Test for TB4: Tor Browser's Firefox preference overrides
+// This is a minimal test to check whether the 000-tor-browser.js
+// pref overrides are being used at all or not. More comprehensive
+// pref tests are maintained in the tor-browser-bundle-testsuite project.
+
+function test() {
+
+let expectedPrefs = [
+   // Homepage
+   ["browser.startup.homepage", "about:tor"],
+
+   // Disable the "Refresh" prompt that is displayed for stale profiles.
+   ["browser.disableResetPrompt", true],
+
+   // Version placeholder
+   ["torbrowser.version", "dev-build"],
+  ];
+
+let getPref = function (prefName) {
+  let type = Services.prefs.getPrefType(prefName);
+  if (type === Services.prefs.PREF_INT) return Services.prefs.getIntPref(prefName);
+  if (type === Services.prefs.PREF_BOOL) return Services.prefs.getBoolPref(prefName);
+  if (type === Services.prefs.PREF_STRING) return Services.prefs.getCharPref(prefName);
+  // Something went wrong.
+  throw new Error("Can't access pref " + prefName);
+};
+
+let testPref = function([key, expectedValue]) {
+  let foundValue = getPref(key);
+  is(foundValue, expectedValue, "Pref '" + key + "' should be '" + expectedValue +"'.");
+};  
+
+expectedPrefs.map(testPref);
+
+} // end function test()
diff --git a/tbb-tests/browser_tor_bug2950.js b/tbb-tests/browser_tor_bug2950.js
new file mode 100644
index 000000000000..16e41344a3c4
--- /dev/null
+++ b/tbb-tests/browser_tor_bug2950.js
@@ -0,0 +1,74 @@
+// # Regression tests for tor Bug #2950, Make Permissions Manager memory-only
+// Ensures that permissions.sqlite file in profile directory is not written to,
+// even when we write a value to Firefox's permissions database.
+
+// The requisite test() function.
+function test() {
+
+// Needed because of asynchronous part later in the test.
+waitForExplicitFinish();
+
+// Shortcut
+let Ci = Components.interfaces;
+
+// ## utility functions
+
+// __principal(spec)__.
+// Creates a principal instance from a spec
+// (string address such as "https://www.torproject.org";).
+let principal = spec => Services.scriptSecurityManager.createContentPrincipalFromOrigin(spec);
+
+// __setPermission(spec, key, value)__.
+// Sets the site permission of type key to value, for the site located at address spec.
+let setPermission = (spec, key, value) => SitePermissions.setForPrincipal(principal(spec), key, value);
+
+// __getPermission(spec, key)__.
+// Reads the site permission value for permission type key, for the site
+// located at address spec.
+let getPermission = (spec, key) => SitePermissions.getForPrincipal(principal(spec), key);
+
+// __profileDirPath__.
+// The Firefox Profile directory. Expected location of various persistent files.
+let profileDirPath = Services.dirsvc.get("ProfD", Components.interfaces.nsIFile).path;
+
+// __fileInProfile(fileName)__.
+// Returns an nsIFile instance corresponding to a file in the Profile directory.
+let fileInProfile = fileName => FileUtils.File(profileDirPath + "/" + fileName);
+
+// ## Now let's run the test.
+
+let SITE = "https://www.torproject.org";,
+    KEY = "popup";
+
+let permissionsFile = fileInProfile("permissions.sqlite"),
+                      lastModifiedTime = null,
+                      newModifiedTime = null;
+if (permissionsFile.exists()) {
+  lastModifiedTime = permissionsFile.lastModifiedTime;
+}
+// Read the original value of the permission.
+let originalValue = getPermission(SITE, KEY);
+
+// We need to delay by at least 1000 ms, because that's the granularity
+// of file time stamps, it seems.
+window.setTimeout(
+  function () {
+    // Set the permission to a new value.
+    setPermission(SITE, KEY, SitePermissions.BLOCK);
+    // Now read back the permission value again.
+    let newReadValue = getPermission(SITE, KEY);
+    // Compare to confirm that the permission
+    // value was successfully changed.
+    Assert.notDeepEqual(originalValue, newReadValue, "Set a value in permissions db (perhaps in memory).");
+    // If file existed or now exists, get the current time stamp.
+    if (permissionsFile.exists()) {
+      newModifiedTime = permissionsFile.lastModifiedTime;
+    }
+    // If file was created or modified since we began this test,
+    // then permissions db is not memory only. Complain!
+    is(lastModifiedTime, newModifiedTime, "Don't write to permissions.sqlite file on disk.");
+    // We are done with the test.
+    finish();
+  }, 1100);
+
+} // test()
diff --git a/tbb-tests/mochitest.ini b/tbb-tests/mochitest.ini
new file mode 100644
index 000000000000..cc5172733bbe
--- /dev/null
+++ b/tbb-tests/mochitest.ini
@@ -0,0 +1,3 @@
+[DEFAULT]
+
+[test_tor_bug2874.html]
diff --git a/tbb-tests/moz.build b/tbb-tests/moz.build
new file mode 100644
index 000000000000..01db60b9c28a
--- /dev/null
+++ b/tbb-tests/moz.build
@@ -0,0 +1,9 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+MOCHITEST_MANIFESTS += ["mochitest.ini"]
+
+BROWSER_CHROME_MANIFESTS += ["browser.ini"]
diff --git a/tbb-tests/test_tor_bug2874.html b/tbb-tests/test_tor_bug2874.html
new file mode 100644
index 000000000000..c0a956e9f687
--- /dev/null
+++ b/tbb-tests/test_tor_bug2874.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Tor bug
+https://trac.torproject.org/projects/tor/ticket/2874
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Tor Bug 2874</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+  is(typeof Components, 'undefined', "The global window object should not expose a Components property to untrusted content.");
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://trac.torproject.org/projects/tor/ticket/2874";>Tor Bug 2874</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild
index bfa04334b3e7..4cddb622218c 100644
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -96,7 +96,8 @@ if CONFIG['MOZ_WEBRTC'] and CONFIG['COMPILE_ENVIRONMENT']:
     ]
 
 if CONFIG['ENABLE_TESTS']:
-    DIRS += ['/testing/specialpowers']
+    DIRS += ['/testing/specialpowers',
+             '/tbb-tests']
 
 DIRS += [
     '/testing/gtest',



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits