GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 1b30b27f authored by Alex Catarineu's avatar Alex Catarineu

Fix performance-observer test

parent 3f07e512
......@@ -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',
......
......@@ -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')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment