From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- testing/web-platform/tests/user-timing/OWNERS | 3 + .../web-platform/tests/user-timing/idlharness.html | 59 ++++ .../user-timing/resources/webperftestharness.js | 155 ++++++++++ .../resources/webperftestharnessextension.js | 199 ++++++++++++ .../user-timing/test_user_timing_clear_marks.html | 134 +++++++++ .../test_user_timing_clear_measures.html | 136 +++++++++ .../user-timing/test_user_timing_entry_type.html | 29 ++ .../tests/user-timing/test_user_timing_exists.html | 28 ++ .../tests/user-timing/test_user_timing_mark.html | 228 ++++++++++++++ ...re_exception_when_invoke_without_parameter.html | 67 +++++ .../test_user_timing_mark_exceptions.html | 105 +++++++ ...me_of_navigation_timing_optional_attribute.html | 55 ++++ .../user-timing/test_user_timing_measure.html | 334 +++++++++++++++++++++ .../test_user_timing_measure_exceptions.html | 282 +++++++++++++++++ ...test_user_timing_measure_navigation_timing.html | 233 ++++++++++++++ 15 files changed, 2047 insertions(+) create mode 100644 testing/web-platform/tests/user-timing/OWNERS create mode 100644 testing/web-platform/tests/user-timing/idlharness.html create mode 100644 testing/web-platform/tests/user-timing/resources/webperftestharness.js create mode 100644 testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_clear_marks.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_clear_measures.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_entry_type.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_exists.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_mark.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_mark_exceptions.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_measure.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_measure_exceptions.html create mode 100644 testing/web-platform/tests/user-timing/test_user_timing_measure_navigation_timing.html (limited to 'testing/web-platform/tests/user-timing') diff --git a/testing/web-platform/tests/user-timing/OWNERS b/testing/web-platform/tests/user-timing/OWNERS new file mode 100644 index 000000000..56997198b --- /dev/null +++ b/testing/web-platform/tests/user-timing/OWNERS @@ -0,0 +1,3 @@ +@plehegar +@igrigorik +@toddreifsteck diff --git a/testing/web-platform/tests/user-timing/idlharness.html b/testing/web-platform/tests/user-timing/idlharness.html new file mode 100644 index 000000000..3ec7e1a17 --- /dev/null +++ b/testing/web-platform/tests/user-timing/idlharness.html @@ -0,0 +1,59 @@ + + + + +User Timing IDL tests + + + + + + + + + + +

User Timing IDL tests

+
+ + + +
+partial interface Performance {
+    void mark(DOMString markName);
+    void clearMarks(optional  DOMString markName);
+
+    void measure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
+    void clearMeasures(optional DOMString measureName);
+};
+
+interface PerformanceMark : PerformanceEntry {
+};
+
+interface PerformanceMeasure : PerformanceEntry {
+};
+
+
+ + + + diff --git a/testing/web-platform/tests/user-timing/resources/webperftestharness.js b/testing/web-platform/tests/user-timing/resources/webperftestharness.js new file mode 100644 index 000000000..750946dde --- /dev/null +++ b/testing/web-platform/tests/user-timing/resources/webperftestharness.js @@ -0,0 +1,155 @@ +/* +Distributed under both the W3C Test Suite License [1] and the W3C +3-clause BSD License [2]. To contribute to a W3C Test Suite, see the +policies and contribution forms [3]. + +[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license +[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license +[3] http://www.w3.org/2004/10/27-testcases + */ + +// +// Helper Functions for NavigationTiming W3C tests +// + +var performanceNamespace = window.performance; +var timingAttributes = [ + 'connectEnd', + 'connectStart', + 'domComplete', + 'domContentLoadedEventEnd', + 'domContentLoadedEventStart', + 'domInteractive', + 'domLoading', + 'domainLookupEnd', + 'domainLookupStart', + 'fetchStart', + 'loadEventEnd', + 'loadEventStart', + 'navigationStart', + 'redirectEnd', + 'redirectStart', + 'requestStart', + 'responseEnd', + 'responseStart', + 'unloadEventEnd', + 'unloadEventStart' +]; + +var namespace_check = false; + +// +// All test() functions in the WebPerf test suite should use wp_test() instead. +// +// wp_test() validates the window.performance namespace exists prior to running tests and +// immediately shows a single failure if it does not. +// + +function wp_test(func, msg, properties) +{ + // only run the namespace check once + if (!namespace_check) + { + namespace_check = true; + + if (performanceNamespace === undefined || performanceNamespace == null) + { + // show a single error that window.performance is undefined + test(function() { assert_true(performanceNamespace !== undefined && performanceNamespace != null, "window.performance is defined and not null"); }, "window.performance is defined and not null.", {author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } + } + + test(func, msg, properties); +} + +function test_namespace(child_name, skip_root) +{ + if (skip_root === undefined) { + var msg = 'window.performance is defined'; + wp_test(function () { assert_true(performanceNamespace !== undefined, msg); }, msg,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } + + if (child_name !== undefined) { + var msg2 = 'window.performance.' + child_name + ' is defined'; + wp_test(function() { assert_true(performanceNamespace[child_name] !== undefined, msg2); }, msg2,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } +} + +function test_attribute_exists(parent_name, attribute_name, properties) +{ + var msg = 'window.performance.' + parent_name + '.' + attribute_name + ' is defined.'; + wp_test(function() { assert_true(performanceNamespace[parent_name][attribute_name] !== undefined, msg); }, msg, properties); +} + +function test_enum(parent_name, enum_name, value, properties) +{ + var msg = 'window.performance.' + parent_name + '.' + enum_name + ' is defined.'; + wp_test(function() { assert_true(performanceNamespace[parent_name][enum_name] !== undefined, msg); }, msg, properties); + + msg = 'window.performance.' + parent_name + '.' + enum_name + ' = ' + value; + wp_test(function() { assert_equals(performanceNamespace[parent_name][enum_name], value, msg); }, msg, properties); +} + +function test_timing_order(attribute_name, greater_than_attribute, properties) +{ + // ensure it's not 0 first + var msg = "window.performance.timing." + attribute_name + " > 0"; + wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] > 0, msg); }, msg, properties); + + // ensure it's in the right order + msg = "window.performance.timing." + attribute_name + " >= window.performance.timing." + greater_than_attribute; + wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] >= performanceNamespace.timing[greater_than_attribute], msg); }, msg, properties); +} + +function test_timing_greater_than(attribute_name, greater_than, properties) +{ + var msg = "window.performance.timing." + attribute_name + " > " + greater_than; + test_greater_than(performanceNamespace.timing[attribute_name], greater_than, msg, properties); +} + +function test_timing_equals(attribute_name, equals, msg, properties) +{ + var test_msg = msg || "window.performance.timing." + attribute_name + " == " + equals; + test_equals(performanceNamespace.timing[attribute_name], equals, test_msg, properties); +} + +// +// Non-test related helper functions +// + +function sleep_milliseconds(n) +{ + var start = new Date().getTime(); + while (true) { + if ((new Date().getTime() - start) >= n) break; + } +} + +// +// Common helper functions +// + +function test_true(value, msg, properties) +{ + wp_test(function () { assert_true(value, msg); }, msg, properties); +} + +function test_equals(value, equals, msg, properties) +{ + wp_test(function () { assert_equals(value, equals, msg); }, msg, properties); +} + +function test_greater_than(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties); +} + +function test_greater_or_equals(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties); +} + +function test_not_equals(value, notequals, msg, properties) +{ + wp_test(function() { assert_true(value !== notequals, msg); }, msg, properties); +} diff --git a/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js b/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js new file mode 100644 index 000000000..579ee9096 --- /dev/null +++ b/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js @@ -0,0 +1,199 @@ +/* +Distributed under both the W3C Test Suite License [1] and the W3C +3-clause BSD License [2]. To contribute to a W3C Test Suite, see the +policies and contribution forms [3]. + +[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license +[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license +[3] http://www.w3.org/2004/10/27-testcases + */ + +var mark_names = [ + '', + '1', + 'abc', +]; + +var measures = [ + [''], + ['2', 1], + ['aaa', 'navigationStart', ''], +]; + +function test_method_exists(method, method_name, properties) +{ + var msg; + if (typeof method === 'function') + msg = 'performance.' + method.name + ' is supported!'; + else + msg = 'performance.' + method_name + ' is supported!'; + wp_test(function() { assert_true(typeof method === 'function', msg); }, msg, properties); +} + +function test_method_throw_exception(func_str, exception, msg) +{ + var exception_name = typeof exception === "object" ? exception.name : exception; + var msg = 'Invocation of ' + func_str + ' should throw ' + exception_name + ' Exception.'; + wp_test(function() { assert_throws(exception, function() {eval(func_str)}, msg); }, msg); +} + +function test_noless_than(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties); +} + +function test_fail(msg, properties) +{ + wp_test(function() { assert_unreached(); }, msg, properties); +} + +function test_resource_entries(entries, expected_entries) +{ + // This is slightly convoluted so that we can sort the output. + var actual_entries = {}; + var origin = window.location.protocol + "//" + window.location.host; + + for (var i = 0; i < entries.length; ++i) { + var entry = entries[i]; + var found = false; + for (var expected_entry in expected_entries) { + if (entry.name == origin + expected_entry) { + found = true; + if (expected_entry in actual_entries) { + test_fail(expected_entry + ' is not expected to have duplicate entries'); + } + actual_entries[expected_entry] = entry; + break; + } + } + if (!found) { + test_fail(entries[i].name + ' is not expected to be in the Resource Timing buffer'); + } + } + + sorted_urls = []; + for (var i in actual_entries) { + sorted_urls.push(i); + } + sorted_urls.sort(); + for (var i in sorted_urls) { + var url = sorted_urls[i]; + test_equals(actual_entries[url].initiatorType, + expected_entries[url], + origin + url + ' is expected to have initiatorType ' + expected_entries[url]); + } + for (var j in expected_entries) { + if (!(j in actual_entries)) { + test_fail(origin + j + ' is expected to be in the Resource Timing buffer'); + } + } +} +function performance_entrylist_checker(type) +{ + var entryType = type; + + function entry_check(entry, expectedNames) + { + var msg = 'Entry \"' + entry.name + '\" should be one that we have set.'; + wp_test(function() { assert_in_array(entry.name, expectedNames, msg); }, msg); + test_equals(entry.entryType, entryType, 'entryType should be \"' + entryType + '\".'); + if (type === "measure") { + test_true(isFinite(entry.startTime), 'startTime should be a number.'); + test_true(isFinite(entry.duration), 'duration should be a number.'); + } else if (type === "mark") { + test_greater_than(entry.startTime, 0, 'startTime should greater than 0.'); + test_equals(entry.duration, 0, 'duration of mark should be 0.'); + } + } + + function entrylist_order_check(entryList) + { + var inOrder = true; + for (var i = 0; i < entryList.length - 1; ++i) + { + if (entryList[i + 1].startTime < entryList[i].startTime) { + inOrder = false; + break; + } + } + return inOrder; + } + + function entrylist_check(entryList, expectedLength, expectedNames) + { + test_equals(entryList.length, expectedLength, 'There should be ' + expectedLength + ' entries.'); + test_true(entrylist_order_check(entryList), 'Entries in entrylist should be in order.'); + for (var i = 0; i < entryList.length; ++i) + { + entry_check(entryList[i], expectedNames); + } + } + + return{"entrylist_check":entrylist_check}; +} + +function PerformanceContext(context) +{ + this.performanceContext = context; +} + +PerformanceContext.prototype = +{ + + initialMeasures: function(item, index, array) + { + this.performanceContext.measure.apply(this.performanceContext, item); + }, + + mark: function() + { + this.performanceContext.mark.apply(this.performanceContext, arguments); + }, + + measure: function() + { + this.performanceContext.measure.apply(this.performanceContext, arguments); + }, + + clearMarks: function() + { + this.performanceContext.clearMarks.apply(this.performanceContext, arguments); + }, + + clearMeasures: function() + { + this.performanceContext.clearMeasures.apply(this.performanceContext, arguments); + + }, + + getEntries: function() + { + return this.performanceContext.getEntries.apply(this.performanceContext, arguments); + }, + + getEntriesByType: function() + { + return this.performanceContext.getEntriesByType.apply(this.performanceContext, arguments); + }, + + getEntriesByName: function() + { + return this.performanceContext.getEntriesByName.apply(this.performanceContext, arguments); + }, + + setResourceTimingBufferSize: function() + { + return this.performanceContext.setResourceTimingBufferSize.apply(this.performanceContext, arguments); + }, + + registerResourceTimingBufferFullCallback: function(func) + { + this.performanceContext.onresourcetimingbufferfull = func; + }, + + clearResourceTimings: function() + { + this.performanceContext.clearResourceTimings.apply(this.performanceContext, arguments); + } + +}; diff --git a/testing/web-platform/tests/user-timing/test_user_timing_clear_marks.html b/testing/web-platform/tests/user-timing/test_user_timing_clear_marks.html new file mode 100644 index 000000000..3056ddbb4 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_clear_marks.html @@ -0,0 +1,134 @@ + + + + + window.performance User Timing clearMarks() method is working properly + + + + + + + + + +

Description

+

This test validates that the performance.clearMarks() method is working properly. This test creates the + following marks to test this method: +

+ After creating each mark, performance.clearMarks() is called three times. First, it is provided with a name + of "markUndefined", a non-existent mark, which shouldn't change the state of the Performance Timeline. Next, + it is provided with a name of "mark2", after which, this mark should no longer be present in the Performance + Timeline. Finally, performance.clearMarks() is called without any name provided. After this call, no marks + should be present in the Performance Timeline. The state of the Performance Timeline is tested with the + performance.getEntriesByType() and performance.getEntries() methods. +

+ +
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_clear_measures.html b/testing/web-platform/tests/user-timing/test_user_timing_clear_measures.html new file mode 100644 index 000000000..68af877e7 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_clear_measures.html @@ -0,0 +1,136 @@ + + + + + window.performance User Timing clearMeasures() method is working properly + + + + + + + + + +

Description

+

This test validates that the performance.clearMeasures() method is working properly. This test creates the + following measures to test this method: +

+ After creating each measure, performance.clearMeasures() is called three times. First, it is provided with a + name of "measureUndefined", a non-existent measure, which shouldn't change the state of the Performance + Timeline. Next, it is provided with a name of "measure2", after which, this measure should no longer be + present in the Performance Timeline. Finally, performance.clearMeasures() is called without any name + provided. After this call, no measures should be present in the Performance Timeline. The state of the + Performance Timeline is tested with the performance.getEntriesByType() and performance.getEntries() methods. +

+ +
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_entry_type.html b/testing/web-platform/tests/user-timing/test_user_timing_entry_type.html new file mode 100644 index 000000000..c9b336b37 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_entry_type.html @@ -0,0 +1,29 @@ + + + + + user timing entry type + + + + + + + + +

Description

+

This test validates the user timing entry type, PerformanceMark and PerformanceMeasure.

+ +
+ + + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_exists.html b/testing/web-platform/tests/user-timing/test_user_timing_exists.html new file mode 100644 index 000000000..9ddfbfcbe --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_exists.html @@ -0,0 +1,28 @@ + + + + + window.performance User Timing exists + + + + + + + + +

Description

+

This test validates that all of the methods used to interact with the User Timing API are defined.

+ +
+ + + + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_mark.html b/testing/web-platform/tests/user-timing/test_user_timing_mark.html new file mode 100644 index 000000000..57e8012b2 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_mark.html @@ -0,0 +1,228 @@ + + + + + window.performance User Timing mark() method is working properly + + + + + + + + + +

Description

+

This test validates that the performance.mark() method is working properly. This test creates the + following marks to test this method: +

+ After creating each mark, the existence of these marks is validated by calling + performance.getEntriesByName() (both with and without the entryType parameter provided), + performance.getEntriesByType(), and performance.getEntries() +

+ +
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html b/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html new file mode 100644 index 000000000..e4e9bfe24 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html @@ -0,0 +1,67 @@ + + + + + exception test of performance.mark and performance.measure + + + + + + + + +

Description

+

This test validates exception scenarios of invoking mark() and measure() without parameter.

+
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_mark_exceptions.html b/testing/web-platform/tests/user-timing/test_user_timing_mark_exceptions.html new file mode 100644 index 000000000..1fe214f78 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_mark_exceptions.html @@ -0,0 +1,105 @@ + + + + + window.performance User Timing mark() method is throwing the proper exceptions + + + + + + + + + +

Description

+

This test validates that the performance.mark() method throws a SYNTAX_ERR exception whenever a navigation + timing attribute is provided for the name parameter. +

+ +
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html b/testing/web-platform/tests/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html new file mode 100644 index 000000000..9532964ef --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html @@ -0,0 +1,55 @@ + + + + + exception test of performance.mark + + + + + + + + + +

Description

+

This test validates exception scenarios of invoking performance.mark() with param of "secureConnectionStart".

+
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_measure.html b/testing/web-platform/tests/user-timing/test_user_timing_measure.html new file mode 100644 index 000000000..6dee57c36 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_measure.html @@ -0,0 +1,334 @@ + + + + + window.performance User Timing measure() method is working properly + + + + + + + + + +

Description

+

This test validates that the performance.measure() method is working properly. This test creates the + following measures to test this method: +

+ After creating each measure, the existence of these measures is validated by calling + performance.getEntriesByName() (both with and without the entryType parameter provided), + performance.getEntriesByType(), and performance.getEntries() +

+ +
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_measure_exceptions.html b/testing/web-platform/tests/user-timing/test_user_timing_measure_exceptions.html new file mode 100644 index 000000000..18a8ba1af --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_measure_exceptions.html @@ -0,0 +1,282 @@ + + + + + window.performance User Timing measure() method is throwing the proper exceptions + + + + + + + + + +

Description

+

This test validates that the performance.measure() method throws a SYNTAX_ERR exception whenever a + non-existent mark is provided as the startMark or endMark, and the method also throws a INVALID_ACCESS_ERR + whenever a navigation timing attribute with a value of zero is provided as the startMark or endMark. +

+ +
+ + diff --git a/testing/web-platform/tests/user-timing/test_user_timing_measure_navigation_timing.html b/testing/web-platform/tests/user-timing/test_user_timing_measure_navigation_timing.html new file mode 100644 index 000000000..d29f4e5e6 --- /dev/null +++ b/testing/web-platform/tests/user-timing/test_user_timing_measure_navigation_timing.html @@ -0,0 +1,233 @@ + + + + + window.performance User Timing clearMeasures() method is working properly with navigation timing + attributes + + + + + + + + + +

Description

+

This test validates that the performance.measure() method is working properly when navigation timing + attributes are used in place of mark names. This test creates the following measures to test this method: +

+ After creating each measure, the existence of these measures is validated by calling + performance.getEntriesByName() with each measure name +

+ +
+ + -- cgit v1.2.3