summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/user-timing
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/user-timing')
-rw-r--r--testing/web-platform/tests/user-timing/resources/webperftestharness.js2
-rw-r--r--testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.html32
-rw-r--r--testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.js14
3 files changed, 47 insertions, 1 deletions
diff --git a/testing/web-platform/tests/user-timing/resources/webperftestharness.js b/testing/web-platform/tests/user-timing/resources/webperftestharness.js
index 750946dde..f1597bbe7 100644
--- a/testing/web-platform/tests/user-timing/resources/webperftestharness.js
+++ b/testing/web-platform/tests/user-timing/resources/webperftestharness.js
@@ -12,7 +12,7 @@ policies and contribution forms [3].
// Helper Functions for NavigationTiming W3C tests
//
-var performanceNamespace = window.performance;
+var performanceNamespace = self.performance;
var timingAttributes = [
'connectEnd',
'connectStart',
diff --git a/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.html b/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.html
new file mode 100644
index 000000000..aea8cb6e9
--- /dev/null
+++ b/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>exception test of performance.mark and performance.measure</title>
+ <meta rel="help" href="http://www.w3.org/TR/user-timing/#extensions-performance-interface"/>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="resources/webperftestharness.js"></script>
+ </head>
+ <body>
+ <script>
+ setup({explicit_done: true});
+ test_namespace();
+
+ test(function() {
+ for (var i in timingAttributes) {
+ assert_throws("SyntaxError", function() { window.performance.mark(timingAttributes[i]); });
+ assert_throws("SyntaxError", function() { window.performance.measure(timingAttributes[i]); });
+ }
+ }, "performance.mark and performance.measure should throw if used with timing attribute values");
+
+ fetch_tests_from_worker(new Worker("test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.js"));
+
+ done();
+
+ </script>
+ <h1>Description</h1>
+ <p>This test validates exception scenarios of invoking mark() and measure() with timing attributes as value.</p>
+ <div id="log"></div>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.js b/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.js
new file mode 100644
index 000000000..f015402f9
--- /dev/null
+++ b/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.js
@@ -0,0 +1,14 @@
+importScripts("/resources/testharness.js");
+importScripts("resources/webperftestharness.js");
+
+test(function() {
+ for (var i in timingAttributes) {
+ performance.mark(timingAttributes[i]);
+ performance.clearMarks(timingAttributes[i]);
+
+ performance.measure(timingAttributes[i]);
+ performance.clearMeasures(timingAttributes[i]);
+ }
+}, "performance.mark and performance.measure should not throw if used with timing attribute values in workers");
+
+done();