From d564205c583cb6b95487c237fbe05e08ed53a915 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Apr 2018 12:18:35 +0200 Subject: Bug 1313420 - Implement Performance.timeOrigin - part 2 - tests https://hg.mozilla.org/mozilla-central/rev/c22f17e0db9d --- dom/events/test/test_eventTimeStamp.html | 36 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'dom/events') diff --git a/dom/events/test/test_eventTimeStamp.html b/dom/events/test/test_eventTimeStamp.html index 107a21f87..056203e92 100644 --- a/dom/events/test/test_eventTimeStamp.html +++ b/dom/events/test/test_eventTimeStamp.html @@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=77992 @@ -57,9 +57,9 @@ function testRegularEvents() { finishTests(); return; } - var timeBeforeEvent = window.performance.now(); - window.addEventListener("load", function(evt) { - var timeAfterEvent = window.performance.now(); + var timeBeforeEvent = performance.now(); + addEventListener("load", function(evt) { + var timeAfterEvent = performance.now(); ok(evt.timeStamp >= timeBeforeEvent && evt.timeStamp <= timeAfterEvent, "Event timestamp (" + evt.timeStamp + ") is in expected range: (" + @@ -71,19 +71,18 @@ function testRegularEvents() { function testWorkerEvents() { var blob = new Blob([ document.getElementById("worker-src").textContent ], { type: "text/javascript" }); - var worker = new Worker(window.URL.createObjectURL(blob)); + var worker = new Worker(URL.createObjectURL(blob)); worker.onmessage = function(evt) { - var timeAfterEvent = window.performance.now(); - // Comparing times across timelines may break now - // ok(evt.data >= timeBeforeEvent && - // evt.data <= timeAfterEvent, + var timeAfterEvent = performance.now() + performance.timeOrigin; + ok(evt.data >= timeBeforeEvent && + evt.data <= timeAfterEvent, // "Event timestamp in dedicated worker (" + evt.data + // ") is in expected range: (" + // timeBeforeEvent + ", " + timeAfterEvent + ")"); worker.terminate(); testSharedWorkerEvents(); }; - var timeBeforeEvent = window.performance.now(); + var timeBeforeEvent = performance.now() + performance.timeOrigin; worker.postMessage(""); } @@ -93,17 +92,16 @@ function testSharedWorkerEvents() { { type: "text/javascript" }); // Delay creation of worker slightly so it is easier to distinguish // shared worker creation time from this document's navigation start - window.setTimeout(function() { - var timeBeforeWorkerCreation = window.performance.now(); - var worker = new SharedWorker(window.URL.createObjectURL(blob)); + setTimeout(function() { + var timeBeforeEvent = performance.now() + performance.timeOrigin; + var worker = new SharedWorker(URL.createObjectURL(blob)); worker.port.onmessage = function(evt) { - var timeAfterEvent = window.performance.now(); - // Comparing times across timelines may break now - // ok(evt.data >= 0 && - // evt.data <= timeAfterEvent - timeBeforeWorkerCreation, + var timeAfterEvent = performance.now() + performance.timeOrigin; + ok(evt.data >= timeBeforeEvent && + evt.data <= timeAfterEvent, // "Event timestamp in shared worker (" + evt.data + // ") is in expected range: (0, " + - // (timeAfterEvent - timeBeforeWorkerCreation) + ")"); + // timeBeforeEvent + ", " + timeAfterEvent + ")"); worker.port.close(); finishTests(); }; -- cgit v1.2.3