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.

Unverified Commit 91f5e2b8 authored by boklm's avatar boklm
Browse files

Bug 19039: Test User Timing API in a worker context

parent 5d80a721
......@@ -336,6 +336,20 @@ our @tests = (
# 'dom.enable_user_timing' => 'true',
#},
},
{
name => 'user-timing-worker',
type => 'marionette',
marionette_test => 'page',
remote => 0,
timeout => 500,
descr => 'Check that the User Timing API in Worker context is really disabled',
use_net => 1,
# To check that the test fails when user timing is enabled,
# uncomment this:
#prefs => {
# 'dom.enable_user_timing' => 'true',
#},
},
{
name => 'performance-observer',
type => 'marionette',
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>user-timing-worker</title>
</head>
<body>
</body>
<script>
var myWorkerMeasure = new Worker('data:text/javascript,onmessage = function(e) { var pass = false; try { performance.measure("measure1"); } catch (e) { pass = true; } postMessage(pass);}');
var myWorkerMark = new Worker('data:text/javascript,onmessage = function(e) { var pass = false; try { performance.mark("startTask1"); } catch (e) { pass = true; } postMessage(pass);}');
var measure_result = false;
var mark_result = false;
var added_result = false;
myWorkerMeasure.onmessage = function(e) {
console.log('Message received from worker');
measure_result = e.data;
if (added_result)
return;
if (!e.data || (measure_result && mark_result)) {
added_result = true;
var result = document.createElement('div');
if (measure_result && mark_result) {
result.innerHTML = 'OK';
} else {
result.innerHTML = 'NOT OK';
}
result.setAttribute("id", "test_result");
document.getElementsByTagName("body")[0].appendChild(result);
}
};
myWorkerMark.onmessage = function(e) {
console.log('Message received from worker');
mark_result = e.data;
if (added_result)
return;
if (!e.data || (measure_result && mark_result)) {
added_result = true;
var result = document.createElement('div');
if (measure_result && mark_result) {
result.innerHTML = 'OK';
} else {
result.innerHTML = 'NOT OK';
}
result.setAttribute("id", "test_result");
document.getElementsByTagName("body")[0].appendChild(result);
}
};
myWorkerMeasure.postMessage([]);
myWorkerMark.postMessage([]);
myWorkerMeasure.postMessage([]);
myWorkerMark.postMessage([]);
</script>
</html>
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