| Index: LayoutTests/http/tests/w3c/webperf/submission/Google/HighResolutionTime/worker-shared-basic.html
|
| diff --git a/LayoutTests/http/tests/w3c/webperf/submission/Google/HighResolutionTime/worker-shared-basic.html b/LayoutTests/http/tests/w3c/webperf/submission/Google/HighResolutionTime/worker-shared-basic.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2d949a2890201672383c660ed007a7faf03b0b09
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/w3c/webperf/submission/Google/HighResolutionTime/worker-shared-basic.html
|
| @@ -0,0 +1,70 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<meta charset="utf-8" />
|
| +<title>window.performance.now in shared workers</title>
|
| +<link rel="author" title="Google" href="http://www.google.com/" />
|
| +<link rel="help" href="https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime2/Overview.html"/>
|
| +<script src="/w3c/resources/testharness.js"></script>
|
| +<script src="/w3c/resources/testharnessreport.js"></script>
|
| +<script src="/w3c/webperf/resources/webperftestharness.js"></script>
|
| +<link rel="stylesheet" href="/w3c/resources/testharness.css" />
|
| +<script>
|
| +setup({explicit_done: true, timeout:10000});
|
| +
|
| +var tests = [
|
| + '"performance" in self;',
|
| + '"now" in self.performance;',
|
| + 'self.performance.now();',
|
| +];
|
| +
|
| +var startTime = window.performance.now();
|
| +var worker = new SharedWorker("/w3c/webperf/resources/worker.js");
|
| +
|
| +worker.port.onmessage = function(event) {
|
| + results = JSON.parse(event.data);
|
| + assert_true(results.length == 3);
|
| + test_true(results[0], "self.performance is defined");
|
| + test_true(results[1], "self.performance.now is defined");
|
| + test_greater_than(startTime, results[2], "Time since origin time should be greater in the main document than the worker");
|
| + setupIframe();
|
| +}
|
| +
|
| +window.iframeStartTime = 0;
|
| +window.test_iframe = function(event, iframeNow) {
|
| + var workerTime = JSON.parse(event.data);
|
| + test_greater_than(workerTime, window.iframeStartTime, "Time since origin time should be greater in the worker than the iframe", {});
|
| + worker.port.postMessage(["close();"]);
|
| + done();
|
| +}
|
| +
|
| +function start() {
|
| + worker.port.postMessage(JSON.stringify(tests));
|
| +}
|
| +
|
| +function setupIframe() {
|
| + var iframe = document.createElement("iframe");
|
| + var body = document.getElementsByTagName("body")[0];
|
| + body.appendChild(iframe);
|
| + var script = iframe.contentWindow.document.createElement("script");
|
| + script.innerHTML =
|
| + "window.top.iframeStartTime = window.performance.now();" +
|
| + "var worker = new SharedWorker('/w3c/webperf/resources/worker.js');" +
|
| + "worker.port.onmessage = function(event) {" +
|
| + " window.top.test_iframe(event);" +
|
| + "};" +
|
| + "worker.port.postMessage(JSON.stringify(['self.performance.now();']));";
|
| + iframe.contentWindow.document.body.appendChild(script);
|
| +}
|
| +
|
| +window.addEventListener("load", start);
|
| +</script>
|
| +</head>
|
| +<body>
|
| +<h1>Description</h1>
|
| +<p>This test validates that performance.now() exists in shared workers and reports reasonable times.</p>
|
| +
|
| +<div id="log"></div>
|
| +
|
| +</body>
|
| +</html>
|
|
|