summaryrefslogtreecommitdiffstats
path: root/dom/performance/tests
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 12:18:35 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 12:18:35 +0200
commitd564205c583cb6b95487c237fbe05e08ed53a915 (patch)
tree6c42d050ac33a1490e3ae5a8cc7f75951976cde1 /dom/performance/tests
parent98438fa32e4f93b59359662188e164c7c828acb7 (diff)
downloadUXP-d564205c583cb6b95487c237fbe05e08ed53a915.tar
UXP-d564205c583cb6b95487c237fbe05e08ed53a915.tar.gz
UXP-d564205c583cb6b95487c237fbe05e08ed53a915.tar.lz
UXP-d564205c583cb6b95487c237fbe05e08ed53a915.tar.xz
UXP-d564205c583cb6b95487c237fbe05e08ed53a915.zip
Bug 1313420 - Implement Performance.timeOrigin - part 2 - tests
https://hg.mozilla.org/mozilla-central/rev/c22f17e0db9d
Diffstat (limited to 'dom/performance/tests')
-rw-r--r--dom/performance/tests/mochitest.ini1
-rw-r--r--dom/performance/tests/test_timeOrigin.html68
2 files changed, 69 insertions, 0 deletions
diff --git a/dom/performance/tests/mochitest.ini b/dom/performance/tests/mochitest.ini
index 7005637e1..bee0b2e70 100644
--- a/dom/performance/tests/mochitest.ini
+++ b/dom/performance/tests/mochitest.ini
@@ -13,3 +13,4 @@ support-files =
[test_worker_observer.html]
[test_sharedWorker_performance_user_timing.html]
[test_worker_performance_now.html]
+[test_timeOrigin.html]
diff --git a/dom/performance/tests/test_timeOrigin.html b/dom/performance/tests/test_timeOrigin.html
new file mode 100644
index 000000000..5a8a461f3
--- /dev/null
+++ b/dom/performance/tests/test_timeOrigin.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Test for performance.timeOrigin</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="test_performance_user_timing.js"></script>
+ </head>
+ <body>
+ <script type="text/js-worker" id="worker-src">
+ postMessage({ now: performance.now(), timeOrigin: performance.timeOrigin });
+ </script>
+
+ <script type="text/js-worker" id="shared-worker-src">
+ onconnect = function(evt) {
+ evt.ports[0].postMessage({ now: performance.now(), timeOrigin: performance.timeOrigin });
+ };
+ </script>
+
+ <script class="testbody" type="text/javascript">
+
+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.now + e.timeOrigin > now + performance.now, "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.now + e.timeOrigin > now + performance.now, "Comparing worker.now and window.now");
+ next();
+ }
+}
+
+var tests = [ testBasic, testWorker, testSharedWorker ];
+function next() {
+ if (!tests.length) {
+ SimpleTest.finish();
+ return;
+ }
+
+ var test = tests.shift();
+ test();
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(next);
+ </script>
+ </pre>
+ </body>
+</html>