function testBasic() {
ok("timeOrigin" in performance, "Performance.timeOrigin exists.");
ok(performance.timeOrigin > 0, "TimeOrigin must be greater than 0.");
next();
}
function testWorker() { var now = performance.now();
var blob = new Blob([ document.getElementById("worker-src").textContent ],
{ type: "text/javascript" }); var w = new Worker(URL.createObjectURL(blob));
w.onmessage = function(e) {
ok (e.data.now + e.data.timeOrigin > now + performance.timeOrigin, "Comparing worker.now and window.now");
next();
}
}
function testSharedWorker() { var now = performance.now();
var blob = new Blob([ document.getElementById("shared-worker-src").textContent ],
{ type: "text/javascript" }); var w = new SharedWorker(URL.createObjectURL(blob));
w.port.onmessage = function(e) {
ok (e.data.now + e.data.timeOrigin > now + performance.timeOrigin, "Comparing worker.now and window.now");
next();
}
}
var tests = [ testBasic, testWorker, testSharedWorker ];
function next() {
if (!tests.length) {
SpecialPowers.setBoolPref("privacy.reduceTimerPrecision", reduceTimePrecisionPrevPrefValue);
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
SimpleTest.waitForExplicitFinish();
// It is a known issue that comparing time between a worker and a window
// when timer clamping is in effect may cause time to go backwards.
// Do not run this test with this preference set. For large values of
// clamping you will see failures. For small values, it is intermitant. var reduceTimePrecisionPrevPrefValue = SpecialPowers.getBoolPref("privacy.reduceTimerPrecision");
SpecialPowers.setBoolPref("privacy.reduceTimerPrecision", false);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.