[tbb-commits] [tor-browser-bundle-testsuite/master] Fix performance-observer test
gk at torproject.org
gk at torproject.org
Thu Oct 15 18:41:27 UTC 2020
commit 1b30b27ffd9af1ef9a0a6bd81e3c1247a7e96637
Author: Alex Catarineu <acat at torproject.org>
Date: Mon May 18 08:56:21 2020 +0200
Fix performance-observer test
---
TBBTestSuite/TestSuite/BrowserBundleTests.pm | 7 ----
.../tor_browser_tests/test_performance-observer.py | 38 ++++++++++++----------
2 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/TBBTestSuite/TestSuite/BrowserBundleTests.pm b/TBBTestSuite/TestSuite/BrowserBundleTests.pm
index e35e903..0bf4359 100644
--- a/TBBTestSuite/TestSuite/BrowserBundleTests.pm
+++ b/TBBTestSuite/TestSuite/BrowserBundleTests.pm
@@ -380,13 +380,6 @@ our @tests = (
type => 'marionette',
descr => 'Check that the Performance Observer API is really disabled',
use_net => 1,
- # To check that the test fails when performance observer is enabled,
- # uncomment this:
- #prefs => {
- # 'dom.enable_performance_observer' => 'true',
- #},
- # Bug 27137: temporarily disable test
- enable => sub { undef },
},
{
name => 'searchengines',
diff --git a/marionette/tor_browser_tests/test_performance-observer.py b/marionette/tor_browser_tests/test_performance-observer.py
index 31c3c5f..b727a01 100644
--- a/marionette/tor_browser_tests/test_performance-observer.py
+++ b/marionette/tor_browser_tests/test_performance-observer.py
@@ -4,9 +4,6 @@
# Setting |dom.enable_performance_observer| to |false| and testing that
# might not be sufficient.
-from marionette_driver import By
-from marionette_driver.errors import MarionetteException
-
from marionette_harness import MarionetteTestCase
class Test(MarionetteTestCase):
@@ -19,18 +16,25 @@ class Test(MarionetteTestCase):
def test_performance_observer(self):
+ def is_perf_obs_working(marionette):
+ return self.marionette.execute_async_script("""
+ let [resolve] = arguments;
+ var observer = new PerformanceObserver(function(...args) { resolve(true); });
+ observer.observe({entryTypes: ['resource', 'mark', 'measure']});
+ performance.mark("hello");
+ setTimeout(function() {
+ resolve(false);
+ }, 2000);
+ """)
+
with self.marionette.using_context('content'):
- self.marionette.navigate(self.TEST_URL)
-
- err_msg = 'performance observer is working'
- self.assertTrue(self.marionette.execute_script("""
- var pass = false;
- try {
- var observer = new PerformanceObserver(function(list) { });
- observer.observe({entryTypes: ['resource', 'mark', 'measure']});
- } catch (e) {
- pass = true;
- }
- return pass;
- """),
- msg=err_msg)
+ m = self.marionette
+ m.navigate(self.TEST_URL)
+ m.timeout.script = 10
+
+ # Performance observer should not work with default settings
+ self.assertFalse(is_perf_obs_working(m), 'performance observer is working')
+
+ # Performance observer should work if `privacy.resistFingerprinting = false`
+ with self.marionette.using_prefs({"privacy.resistFingerprinting": False}):
+ self.assertTrue(is_perf_obs_working(m), 'performance observer is not working')
More information about the tbb-commits
mailing list