Implement PerformanceObserver.supportedEntryTypes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 00:04:52 +0000 (00:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 00:04:52 +0000 (00:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193428

LayoutTests/imported/w3c:

Patch by Charles Vazac <cvazac@akamai.com> on 2019-01-24
Reviewed by Joseph Pecoraro.

* web-platform-tests/resource-timing/supported_resource_type.any-expected.txt:
* web-platform-tests/resource-timing/supported_resource_type.any.worker-expected.txt:

Source/WebCore:

PerformanceObserver.supportedEntryTypes should return an array of
entryTypes that can be observed per specification
https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute

Patch by Charles Vazac <cvazac@akamai.com> on 2019-01-24
Reviewed by Joseph Pecoraro.

This is covered by web-platform-tests
LayoutTests/imported/w3c/web-platform-tests/resource-timing/supported_resource_type.*.html.

* page/PerformanceObserver.cpp:
(WebCore::PerformanceObserver::supportedEntryTypes):
* page/PerformanceObserver.h:
* page/PerformanceObserver.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240454 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/performance-timeline/resources/square.png [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/resource-timing/supported_resource_type.any-expected.txt
LayoutTests/imported/w3c/web-platform-tests/resource-timing/supported_resource_type.any.js
LayoutTests/imported/w3c/web-platform-tests/resource-timing/supported_resource_type.any.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.worker-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/user-timing/w3c-import.log
Source/WebCore/ChangeLog
Source/WebCore/page/PerformanceObserver.cpp
Source/WebCore/page/PerformanceObserver.h
Source/WebCore/page/PerformanceObserver.idl

index e771668..ec05741 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-24  Charles Vazac  <cvazac@akamai.com>
+
+        Implement PerformanceObserver.supportedEntryTypes
+        https://bugs.webkit.org/show_bug.cgi?id=193428
+
+        Reviewed by Joseph Pecoraro.
+
+        * web-platform-tests/resource-timing/supported_resource_type.any-expected.txt:
+        * web-platform-tests/resource-timing/supported_resource_type.any.worker-expected.txt:
+
 2019-01-23  Oriol Brufau  <obrufau@igalia.com>
 
         [css-logical] Implement flow-relative inset properties
diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt
new file mode 100644 (file)
index 0000000..57978bf
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL supportedEntryTypes contains 'navigation'. assert_true: There should be an entry 'navigation' in PerformanceObserver.supportedEntryTypes expected true got false
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.html b/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.js b/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.js
new file mode 100644 (file)
index 0000000..3239c7d
--- /dev/null
@@ -0,0 +1,20 @@
+test(() => {
+  if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+    assert_unreached("supportedEntryTypes is not supported.");
+  assert_true(PerformanceObserver.supportedEntryTypes.includes("navigation"),
+    "There should be an entry 'navigation' in PerformanceObserver.supportedEntryTypes");
+}, "supportedEntryTypes contains 'navigation'.");
+
+if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
+  const entryType = "navigation";
+  if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
+    promise_test(async() => {
+      await new Promise((resolve) => {
+        new PerformanceObserver(function (list, observer) {
+          observer.disconnect();
+          resolve();
+        }).observe({entryTypes: [entryType]});
+      })
+    }, `'${entryType}' entries should be observable.`)
+  }
+}
diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt
new file mode 100644 (file)
index 0000000..57978bf
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL supportedEntryTypes contains 'navigation'. assert_true: There should be an entry 'navigation' in PerformanceObserver.supportedEntryTypes expected true got false
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.worker.html b/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/supported_navigation_type.any.worker.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/resources/square.png b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/resources/square.png
new file mode 100644 (file)
index 0000000..be211bc
Binary files /dev/null and b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/resources/square.png differ
diff --git a/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt
new file mode 100644 (file)
index 0000000..4ed68f9
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS supportedEntryTypes exists and returns entries in alphabetical order 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.html b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.js b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.js
new file mode 100644 (file)
index 0000000..a0225ad
--- /dev/null
@@ -0,0 +1,12 @@
+test(() => {
+  if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+    assert_unreached("supportedEntryTypes is not supported.");
+  const types = PerformanceObserver.supportedEntryTypes;
+  assert_greater_than(types.length, 0,
+    "There should be at least one entry in supportedEntryTypes.");
+  for (let i = 1; i < types.length; i++) {
+    assert_true(types[i-1] < types[i],
+      "The strings '" + types[i-1] + "' and '" + types[i] +
+      "' are repeated or they are not in alphabetical order.")
+  }
+}, "supportedEntryTypes exists and returns entries in alphabetical order");
diff --git a/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt
new file mode 100644 (file)
index 0000000..4ed68f9
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS supportedEntryTypes exists and returns entries in alphabetical order 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.worker.html b/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/supportedEntryTypes.any.worker.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
index df46af5..0dc5926 100644 (file)
@@ -1,3 +1,4 @@
 
-FAIL supportedEntryTypes contains 'resource'. assert_unreached: supportedEntryTypes is not supported. Reached unreachable code
+PASS supportedEntryTypes contains 'resource'. 
+PASS 'resource' entries should be observable. 
 
index 6096ad7..31e4009 100644 (file)
@@ -4,3 +4,21 @@
   assert_true(PerformanceObserver.supportedEntryTypes.includes("resource"),
     "There should be an entry 'resource' in PerformanceObserver.supportedEntryTypes");
 }, "supportedEntryTypes contains 'resource'.");
+
+if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
+  const entryType = "resource";
+  if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
+    promise_test(async() => {
+      await new Promise((resolve) => {
+        new PerformanceObserver(function (list, observer) {
+          observer.disconnect();
+          resolve();
+        }).observe({entryTypes: [entryType]});
+
+        // Force the PerformanceEntry.
+        // Use `self` for Workers.
+        fetch(self.location.href + "?" + Math.random());
+      })
+    }, `'${entryType}' entries should be observable.`)
+  }
+}
index df46af5..0dc5926 100644 (file)
@@ -1,3 +1,4 @@
 
-FAIL supportedEntryTypes contains 'resource'. assert_unreached: supportedEntryTypes is not supported. Reached unreachable code
+PASS supportedEntryTypes contains 'resource'. 
+PASS 'resource' entries should be observable. 
 
diff --git a/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any-expected.txt
new file mode 100644 (file)
index 0000000..0298beb
--- /dev/null
@@ -0,0 +1,5 @@
+
+PASS supportedEntryTypes contains 'mark' and 'measure'. 
+PASS 'mark' entries should be observable. 
+PASS 'measure' entries should be observable. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.html b/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.js b/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.js
new file mode 100644 (file)
index 0000000..ea3b2fe
--- /dev/null
@@ -0,0 +1,37 @@
+test(() => {
+  if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+    assert_unreached("supportedEntryTypes is not supported.");
+  const types = PerformanceObserver.supportedEntryTypes;
+  assert_true(types.includes("mark"),
+    "There should be 'mark' in PerformanceObserver.supportedEntryTypes");
+  assert_true(types.includes("measure"),
+    "There should be 'measure' in PerformanceObserver.supportedEntryTypes");
+  assert_greater_than(types.indexOf("measure"), types.indexOf('mark'),
+    "The 'measure' entry should appear after the 'mark' entry");
+}, "supportedEntryTypes contains 'mark' and 'measure'.");
+
+if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
+  const entryTypes = {
+    "mark": () => {
+      performance.mark('foo');
+    },
+    "measure": () => {
+      performance.measure('bar');
+    }
+  }
+  for (let entryType in entryTypes) {
+    if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
+      promise_test(async() => {
+        await new Promise((resolve) => {
+          new PerformanceObserver(function (list, observer) {
+            observer.disconnect();
+            resolve();
+          }).observe({entryTypes: [entryType]});
+
+          // Force the PerformanceEntry.
+          entryTypes[entryType]();
+        })
+      }, `'${entryType}' entries should be observable.`)
+    }
+  }
+}
diff --git a/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.worker-expected.txt
new file mode 100644 (file)
index 0000000..0298beb
--- /dev/null
@@ -0,0 +1,5 @@
+
+PASS supportedEntryTypes contains 'mark' and 'measure'. 
+PASS 'mark' entries should be observable. 
+PASS 'measure' entries should be observable. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.worker.html b/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.worker.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
index 32703cd..a9f3ec8 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
@@ -32,4 +32,5 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/user-timing/measure_exceptions_navigation_timing.html
 /LayoutTests/imported/w3c/web-platform-tests/user-timing/measure_navigation_timing.html
 /LayoutTests/imported/w3c/web-platform-tests/user-timing/measure_syntax_err.any.js
+/LayoutTests/imported/w3c/web-platform-tests/user-timing/supported-usertiming-types.any.js
 /LayoutTests/imported/w3c/web-platform-tests/user-timing/user_timing_exists.any.js
index 84416e4..a112c3f 100644 (file)
@@ -1,3 +1,22 @@
+2019-01-24  Charles Vazac  <cvazac@akamai.com>
+
+        Implement PerformanceObserver.supportedEntryTypes
+        https://bugs.webkit.org/show_bug.cgi?id=193428
+
+        PerformanceObserver.supportedEntryTypes should return an array of
+        entryTypes that can be observed per specification
+        https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
+
+        Reviewed by Joseph Pecoraro.
+
+        This is covered by web-platform-tests
+        LayoutTests/imported/w3c/web-platform-tests/resource-timing/supported_resource_type.*.html.
+
+        * page/PerformanceObserver.cpp:
+        (WebCore::PerformanceObserver::supportedEntryTypes):
+        * page/PerformanceObserver.h:
+        * page/PerformanceObserver.idl:
+
 2019-01-24  Truitt Savell  <tsavell@apple.com>
 
         Unreviewed, rolling out r240446.
index 4a3c9ff..c9e02c3 100644 (file)
@@ -113,4 +113,15 @@ void PerformanceObserver::deliver()
     InspectorInstrumentation::didFireObserverCallback(cookie);
 }
 
+Vector<String> PerformanceObserver::supportedEntryTypes()
+{
+    return {
+        // FIXME: <https://webkit.org/b/184363> Add support for Navigation Timing Level 2
+        // "navigation"_s,
+        "mark"_s,
+        "measure"_s,
+        "resource"_s
+    };
+}
+
 } // namespace WebCore
index 8ab1016..6ab21f0 100644 (file)
@@ -49,6 +49,8 @@ public:
         return adoptRef(*new PerformanceObserver(context, WTFMove(callback)));
     }
 
+    static Vector<String> supportedEntryTypes();
+
     void disassociate();
 
     ExceptionOr<void> observe(Init&&);
index f4914be..87ede75 100644 (file)
@@ -36,6 +36,7 @@
 ] interface PerformanceObserver {
     [MayThrowException] void observe(PerformanceObserverInit options);
     void disconnect();
+    static readonly attribute FrozenArray<DOMString> supportedEntryTypes;
 };
 
 dictionary PerformanceObserverInit {