diff options
Diffstat (limited to 'dom/performance/tests')
-rw-r--r-- | dom/performance/tests/mochitest.ini | 2 | ||||
-rw-r--r-- | dom/performance/tests/performance_observer.html | 74 | ||||
-rw-r--r-- | dom/performance/tests/test_performance_observer.html | 52 | ||||
-rw-r--r-- | dom/performance/tests/test_worker_observer.html | 13 | ||||
-rw-r--r-- | dom/performance/tests/worker_performance_observer.html | 32 |
5 files changed, 53 insertions, 120 deletions
diff --git a/dom/performance/tests/mochitest.ini b/dom/performance/tests/mochitest.ini index 18f7f0e45..7005637e1 100644 --- a/dom/performance/tests/mochitest.ini +++ b/dom/performance/tests/mochitest.ini @@ -1,13 +1,11 @@ [DEFAULT] support-files = - performance_observer.html test_performance_observer.js test_performance_user_timing.js test_worker_performance_now.js worker_performance_user_timing.js worker_performance_observer.js sharedworker_performance_user_timing.js - worker_performance_observer.html [test_performance_observer.html] [test_performance_user_timing.html] diff --git a/dom/performance/tests/performance_observer.html b/dom/performance/tests/performance_observer.html deleted file mode 100644 index b8ced9296..000000000 --- a/dom/performance/tests/performance_observer.html +++ /dev/null @@ -1,74 +0,0 @@ -<!-- - Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ ---> -<!DOCTYPE html> -<meta charset=utf-8> -<html> -<head> -<title>Test for performance observer</title> -<script> -'use strict'; -[ - "promise_test", "test", "setup", - "assert_true", "assert_equals", "assert_array_equals", - "assert_throws", "assert_unreached" -].forEach(func => { - window[func] = opener[func].bind(opener); -}); -function done() { - opener.add_completion_callback(() => { - self.close(); - }); - opener.done(); -} - -</script> -<script src="test_performance_observer.js"></script> -</head> -<body> -<div id="log"></div> -<script> -function makeXHR(aUrl) { - var xmlhttp = new XMLHttpRequest(); - xmlhttp.open("get", aUrl, true); - xmlhttp.send(); -} - -promise_test(t => { - var promise = new Promise(resolve => { - performance.clearResourceTimings(); - - var observer = new PerformanceObserver(list => resolve(list)); - observer.observe({entryTypes: ['resource']}); - t.add_cleanup(() => observer.disconnect()); - }); - - makeXHR("test-data.json"); - - return promise.then(list => { - assert_equals(list.getEntries().length, 1); - assert_array_equals(list.getEntries(), - performance.getEntriesByType("resource"), - "Observed 'resource' entries should equal to entries obtained by getEntriesByType."); - - // getEntries filtering tests - assert_array_equals(list.getEntries({name: "http://mochi.test:8888/tests/dom/base/test/test-data.json"}), - performance.getEntriesByName("http://mochi.test:8888/tests/dom/base/test/test-data.json"), - "getEntries with name filter should return correct results."); - assert_array_equals(list.getEntries({entryType: "resource"}), - performance.getEntriesByType("resource"), - "getEntries with entryType filter should return correct results."); - assert_array_equals(list.getEntries({initiatorType: "xmlhttprequest"}), - performance.getEntriesByType("resource"), - "getEntries with initiatorType filter should return correct results."); - assert_array_equals(list.getEntries({initiatorType: "link"}), - [], - "getEntries with non-existent initiatorType filter should return an empty array."); - }); -}, "resource-timing test"); - -done(); - -</script> -</body> diff --git a/dom/performance/tests/test_performance_observer.html b/dom/performance/tests/test_performance_observer.html index d36878315..7df881bd4 100644 --- a/dom/performance/tests/test_performance_observer.html +++ b/dom/performance/tests/test_performance_observer.html @@ -3,15 +3,55 @@ http://creativecommons.org/publicdomain/zero/1.0/ --> <!DOCTYPE html> +<html> +<head> <meta charset=utf-8> <title>Test for performance observer</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> -<div id=log></div> +</head> +<body> +<div id="log"></div> +<script src="test_performance_observer.js"></script> <script> -'use strict'; -SpecialPowers.pushPrefEnv({"set": [["dom.enable_performance_observer", true]]}, - function() { - window.open("performance_observer.html"); - }); +function makeXHR(aUrl) { + var xmlhttp = new XMLHttpRequest(); + xmlhttp.open("get", aUrl, true); + xmlhttp.send(); +} + +promise_test(t => { + var promise = new Promise(resolve => { + performance.clearResourceTimings(); + + var observer = new PerformanceObserver(list => resolve(list)); + observer.observe({entryTypes: ['resource']}); + t.add_cleanup(() => observer.disconnect()); + }); + + makeXHR("test-data.json"); + + return promise.then(list => { + assert_equals(list.getEntries().length, 1); + assert_array_equals(list.getEntries(), + performance.getEntriesByType("resource"), + "Observed 'resource' entries should equal to entries obtained by getEntriesByType."); + + // getEntries filtering tests + assert_array_equals(list.getEntries({name: "http://mochi.test:8888/tests/dom/base/test/test-data.json"}), + performance.getEntriesByName("http://mochi.test:8888/tests/dom/base/test/test-data.json"), + "getEntries with name filter should return correct results."); + assert_array_equals(list.getEntries({entryType: "resource"}), + performance.getEntriesByType("resource"), + "getEntries with entryType filter should return correct results."); + assert_array_equals(list.getEntries({initiatorType: "xmlhttprequest"}), + performance.getEntriesByType("resource"), + "getEntries with initiatorType filter should return correct results."); + assert_array_equals(list.getEntries({initiatorType: "link"}), + [], + "getEntries with non-existent initiatorType filter should return an empty array."); + }); +}, "resource-timing test"); + </script> +</body> diff --git a/dom/performance/tests/test_worker_observer.html b/dom/performance/tests/test_worker_observer.html index b9ed0c964..9a55ef1d5 100644 --- a/dom/performance/tests/test_worker_observer.html +++ b/dom/performance/tests/test_worker_observer.html @@ -3,15 +3,16 @@ http://creativecommons.org/publicdomain/zero/1.0/ --> <!DOCTYPE html> +<html> +<head> <meta charset=utf-8> <title>Test for performance observer in worker</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> -<div id=log></div> +</head> +<body> +<div id="log"></div> <script> -'use strict'; -SpecialPowers.pushPrefEnv({"set": [["dom.enable_performance_observer", true]]}, - function() { - window.open("worker_performance_observer.html"); - }); +fetch_tests_from_worker(new Worker("worker_performance_observer.js")); </script> +</body> diff --git a/dom/performance/tests/worker_performance_observer.html b/dom/performance/tests/worker_performance_observer.html deleted file mode 100644 index 613762f52..000000000 --- a/dom/performance/tests/worker_performance_observer.html +++ /dev/null @@ -1,32 +0,0 @@ -<!-- - Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ ---> -<!DOCTYPE html> -<meta charset=utf-8> -<html> -<head> -<title>Test for performance observer in worker</title> -</head> -<body> -<div id="log"></div> -<script> -[ - "async_test", "test", "setup", - "assert_true", "assert_equals", "assert_array_equals", - "assert_throws", "fetch_tests_from_worker" -].forEach(func => { - window[func] = opener[func].bind(opener); -}); - -function done() { - opener.add_completion_callback(() => { - self.close(); - }); - opener.done(); -} - -fetch_tests_from_worker(new Worker("worker_performance_observer.js")); -done(); -</script> -</body> |