Title: [265001] trunk
Revision
265001
Author
commit-qu...@webkit.org
Date
2020-07-28 13:03:10 -0700 (Tue, 28 Jul 2020)

Log Message

PerformanceObserver should work with 'type' and not just `entryTypes`
https://bugs.webkit.org/show_bug.cgi?id=209216

Patch by Rob Buis <rb...@igalia.com> on 2020-07-28
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Add po-observe-type.any.html and po-observe-type.any.worker.html tests and
update improved test expectations.

* web-platform-tests/performance-timeline/performanceobservers.js: Added.
(findMatch):
(checkEntries):
(wait):
(checkSorted):
* web-platform-tests/performance-timeline/po-observe-type.any-expected.txt: Added.
* web-platform-tests/performance-timeline/po-observe-type.any.html: Added.
* web-platform-tests/performance-timeline/po-observe-type.any.js: Added.
(test):
(async_test):
* web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt: Added.
* web-platform-tests/performance-timeline/po-observe-type.any.worker.html: Added.
* web-platform-tests/resource-timing/buffered-flag.any-expected.txt:
* web-platform-tests/resource-timing/buffered-flag.any.worker-expected.txt:
* web-platform-tests/resource-timing/object-not-found-adds-entry-expected.txt:
* web-platform-tests/user-timing/buffered-flag.any-expected.txt:
* web-platform-tests/user-timing/buffered-flag.any.worker-expected.txt:

Source/WebCore:

Add support for 'type' attribute as specified here [1].

Tests: imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.html
       imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker.html

[1] https://w3c.github.io/performance-timeline/#dom-performanceobserverinit

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

LayoutTests:

Adjust test to be aligned with the specification and skip
tests that time out.

* TestExpectations:
* performance-api/performance-observer-api-expected.txt:
* performance-api/resources/observer-api.js:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265000 => 265001)


--- trunk/LayoutTests/ChangeLog	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/ChangeLog	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,3 +1,17 @@
+2020-07-28  Rob Buis  <rb...@igalia.com>
+
+        PerformanceObserver should work with 'type' and not just `entryTypes`
+        https://bugs.webkit.org/show_bug.cgi?id=209216
+
+        Reviewed by Youenn Fablet.
+
+        Adjust test to be aligned with the specification and skip
+        tests that time out.
+
+        * TestExpectations:
+        * performance-api/performance-observer-api-expected.txt:
+        * performance-api/resources/observer-api.js:
+
 2020-07-28  Karl Rackler  <rack...@apple.com>
 
         REGRESSION (r264930): [ iOS debug wk2 ] webrtc/video.html is a constant failure

Modified: trunk/LayoutTests/TestExpectations (265000 => 265001)


--- trunk/LayoutTests/TestExpectations	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/TestExpectations	2020-07-28 20:03:10 UTC (rev 265001)
@@ -4881,3 +4881,10 @@
 
 # WebKit2 only.
 js/throw-large-string-oom.html [ Skip ]
+
+webkit.org/b/214884 imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.html [ Skip ]
+webkit.org/b/214884 imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker.html [ Skip ]
+webkit.org/b/214883 imported/w3c/web-platform-tests/resource-timing/buffered-flag.any.html [ Skip ]
+webkit.org/b/214883 imported/w3c/web-platform-tests/resource-timing/buffered-flag.any.worker.html [ Skip ]
+webkit.org/b/214883 imported/w3c/web-platform-tests/user-timing/buffered-flag.any.html [ Skip ]
+webkit.org/b/214883 imported/w3c/web-platform-tests/user-timing/buffered-flag.any.worker.html [ Skip ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265000 => 265001)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,3 +1,31 @@
+2020-07-28  Rob Buis  <rb...@igalia.com>
+
+        PerformanceObserver should work with 'type' and not just `entryTypes`
+        https://bugs.webkit.org/show_bug.cgi?id=209216
+
+        Reviewed by Youenn Fablet.
+
+        Add po-observe-type.any.html and po-observe-type.any.worker.html tests and
+        update improved test expectations.
+
+        * web-platform-tests/performance-timeline/performanceobservers.js: Added.
+        (findMatch):
+        (checkEntries):
+        (wait):
+        (checkSorted):
+        * web-platform-tests/performance-timeline/po-observe-type.any-expected.txt: Added.
+        * web-platform-tests/performance-timeline/po-observe-type.any.html: Added.
+        * web-platform-tests/performance-timeline/po-observe-type.any.js: Added.
+        (test):
+        (async_test):
+        * web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt: Added.
+        * web-platform-tests/performance-timeline/po-observe-type.any.worker.html: Added.
+        * web-platform-tests/resource-timing/buffered-flag.any-expected.txt:
+        * web-platform-tests/resource-timing/buffered-flag.any.worker-expected.txt:
+        * web-platform-tests/resource-timing/object-not-found-adds-entry-expected.txt:
+        * web-platform-tests/user-timing/buffered-flag.any-expected.txt:
+        * web-platform-tests/user-timing/buffered-flag.any.worker-expected.txt:
+
 2020-07-27  Chris Dumez  <cdu...@apple.com>
 
         thisValue is not always set correctly when calling JS callbacks

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/performanceobservers.js (0 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/performanceobservers.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/performanceobservers.js	2020-07-28 20:03:10 UTC (rev 265001)
@@ -0,0 +1,44 @@
+// Compares a performance entry to a predefined one
+// perfEntriesToCheck is an array of performance entries from the user agent
+// expectedEntries is an array of performance entries minted by the test
+function checkEntries(perfEntriesToCheck, expectedEntries) {
+  function findMatch(pe) {
+    // we match based on entryType and name
+    for (var i = expectedEntries.length - 1; i >= 0; i--) {
+      var ex = expectedEntries[i];
+      if (ex.entryType === pe.entryType && ex.name === pe.name) {
+        return ex;
+      }
+    }
+    return null;
+  }
+
+  assert_equals(perfEntriesToCheck.length, expectedEntries.length, "performance entries must match");
+
+  perfEntriesToCheck.forEach(function (pe1) {
+    assert_not_equals(findMatch(pe1), null, "Entry matches");
+  });
+}
+
+// Waits for performance.now to advance. Since precision reduction might
+// cause it to return the same value across multiple calls.
+function wait() {
+  var now = performance.now();
+  while (now === performance.now())
+    continue;
+}
+
+// Ensure the entries list is sorted by startTime.
+function checkSorted(entries) {
+  assert_not_equals(entries.length, 0, "entries list must not be empty");
+  if (!entries.length)
+    return;
+
+  var sorted = false;
+  var lastStartTime = entries[0].startTime;
+  for (var i = 1; i < entries.length; ++i) {
+    var currStartTime = entries[i].startTime;
+    assert_less_than_equal(lastStartTime, currStartTime, "entry list must be sorted by startTime");
+    lastStartTime = currStartTime;
+  }
+}

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any-expected.txt (0 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -0,0 +1,14 @@
+
+Harness Error (TIMEOUT), message = null
+
+PASS Calling observe() without 'type' or 'entryTypes' throws a TypeError 
+FAIL Calling observe() with entryTypes and then type should throw an InvalidModificationError assert_throws_dom: function "function () {
+    obs.observe({type: "measure"});
+  }" did not throw
+FAIL Calling observe() with type and then entryTypes should throw an InvalidModificationError assert_throws_dom: function "function () {
+    obs.observe({entryTypes: ["measure"]});
+  }" did not throw
+PASS Calling observe() with type and entryTypes should throw a TypeError 
+PASS Passing in unknown values to type does throw an exception. 
+TIMEOUT observe() with different type values stacks. Test timed out
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.html (0 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.html	2020-07-28 20:03:10 UTC (rev 265001)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.js (0 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.js	2020-07-28 20:03:10 UTC (rev 265001)
@@ -0,0 +1,64 @@
+// META: script=performanceobservers.js
+
+test(function () {
+  const obs = new PerformanceObserver(() => {});
+  assert_throws_js(TypeError, function () {
+    obs.observe({});
+  });
+  assert_throws_js(TypeError, function () {
+    obs.observe({entryType: ['mark', 'measure']});
+  });
+}, "Calling observe() without 'type' or 'entryTypes' throws a TypeError");
+
+test(() => {
+  const obs = new PerformanceObserver(() =>{});
+  obs.observe({entryTypes: ["mark"]});
+  assert_throws_dom('InvalidModificationError', function () {
+    obs.observe({type: "measure"});
+  });
+}, "Calling observe() with entryTypes and then type should throw an InvalidModificationError");
+
+test(() => {
+  const obs = new PerformanceObserver(() =>{});
+  obs.observe({type: "mark"});
+  assert_throws_dom('InvalidModificationError', function () {
+    obs.observe({entryTypes: ["measure"]});
+  });
+}, "Calling observe() with type and then entryTypes should throw an InvalidModificationError");
+
+test(() => {
+  const obs = new PerformanceObserver(() =>{});
+  assert_throws_js(TypeError, function () {
+    obs.observe({type: "mark", entryTypes: ["measure"]});
+  });
+}, "Calling observe() with type and entryTypes should throw a TypeError");
+
+test(function () {
+  const obs = new PerformanceObserver(() =>{});
+  // Definitely not an entry type.
+  obs.observe({type: "this-cannot-match-an-entryType"});
+  // Close to an entry type, but not quite.
+  obs.observe({type: "marks"});
+}, "Passing in unknown values to type does throw an exception.");
+
+async_test(function (t) {
+  let observedMark = false;
+  let observedMeasure = false;
+  const observer = new PerformanceObserver(
+    t.step_func(function (entryList, obs) {
+      observedMark |= entryList.getEntries().filter(
+        entry => entry.entryType === 'mark').length;
+      observedMeasure |= entryList.getEntries().filter(
+        entry => entry.entryType === 'measure').length
+      // Only conclude the test once we receive both entries!
+      if (observedMark && observedMeasure) {
+        observer.disconnect();
+        t.done();
+      }
+    })
+  );
+  observer.observe({type: "mark"});
+  observer.observe({type: "measure"});
+  self.performance.mark("mark1");
+  self.performance.measure("measure1");
+}, "observe() with different type values stacks.");

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt (0 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -0,0 +1,14 @@
+
+Harness Error (TIMEOUT), message = null
+
+PASS Calling observe() without 'type' or 'entryTypes' throws a TypeError 
+FAIL Calling observe() with entryTypes and then type should throw an InvalidModificationError assert_throws_dom: function "function () {
+    obs.observe({type: "measure"});
+  }" did not throw
+FAIL Calling observe() with type and then entryTypes should throw an InvalidModificationError assert_throws_dom: function "function () {
+    obs.observe({entryTypes: ["measure"]});
+  }" did not throw
+PASS Calling observe() with type and entryTypes should throw a TypeError 
+PASS Passing in unknown values to type does throw an exception. 
+TIMEOUT observe() with different type values stacks. Test timed out
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker.html (0 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker.html	2020-07-28 20:03:10 UTC (rev 265001)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffered-flag.any-expected.txt (265000 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffered-flag.any-expected.txt	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffered-flag.any-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,10 +1,5 @@
-CONSOLE MESSAGE: TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
 
-Harness Error (FAIL), message = TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
+Harness Error (TIMEOUT), message = null
 
 TIMEOUT PerformanceObserver with buffered flag sees previous resource entries. Test timed out
 
-Harness Error (FAIL), message = TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
-
-TIMEOUT PerformanceObserver with buffered flag sees previous resource entries. Test timed out
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffered-flag.any.worker-expected.txt (265000 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffered-flag.any.worker-expected.txt	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffered-flag.any.worker-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,5 +1,5 @@
 
-Harness Error (FAIL), message = Error in remote http://localhost:8800/resource-timing/buffered-flag.any.js: TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
+Harness Error (TIMEOUT), message = null
 
 TIMEOUT PerformanceObserver with buffered flag sees previous resource entries. Test timed out
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/object-not-found-adds-entry-expected.txt (265000 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/object-not-found-adds-entry-expected.txt	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/object-not-found-adds-entry-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,5 +1,6 @@
+ 
 
-FAIL Test that an navigation object with a 404 response displays an entry promise_test: Unhandled rejection with value: object "TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence"
-FAIL Test that an navigation object with a 200 response displays an entry promise_test: Unhandled rejection with value: object "TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence"
-FAIL Test that an image object with a 404 response displays an entry promise_test: Unhandled rejection with value: object "TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence"
+FAIL Test that an navigation object with a 404 response displays an entry assert_unreached: No performance entry was observed Reached unreachable code
+FAIL Test that an navigation object with a 200 response displays an entry assert_unreached: No performance entry was observed Reached unreachable code
+PASS Test that an image object with a 404 response displays an entry 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/buffered-flag.any-expected.txt (265000 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/buffered-flag.any-expected.txt	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/buffered-flag.any-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,13 +1,6 @@
-CONSOLE MESSAGE: TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
-CONSOLE MESSAGE: TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
 
-Harness Error (FAIL), message = TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
+Harness Error (TIMEOUT), message = null
 
 TIMEOUT PerformanceObserver with buffered flag sees previous marks Test timed out
 TIMEOUT PerformanceObserver with buffered flag sees previous measures Test timed out
 
-Harness Error (FAIL), message = TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
-
-TIMEOUT PerformanceObserver with buffered flag sees previous marks Test timed out
-TIMEOUT PerformanceObserver with buffered flag sees previous measures Test timed out
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/buffered-flag.any.worker-expected.txt (265000 => 265001)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/buffered-flag.any.worker-expected.txt	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/buffered-flag.any.worker-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,5 +1,5 @@
 
-Harness Error (FAIL), message = Error in remote http://localhost:8800/user-timing/buffered-flag.any.js: TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence
+Harness Error (TIMEOUT), message = null
 
 TIMEOUT PerformanceObserver with buffered flag sees previous marks Test timed out
 TIMEOUT PerformanceObserver with buffered flag sees previous measures Test timed out

Modified: trunk/LayoutTests/performance-api/performance-observer-api-expected.txt (265000 => 265001)


--- trunk/LayoutTests/performance-api/performance-observer-api-expected.txt	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/performance-api/performance-observer-api-expected.txt	2020-07-28 20:03:10 UTC (rev 265001)
@@ -13,10 +13,10 @@
 PASS observer = new PerformanceObserver(function() {}) did not throw exception.
 PASS observer.observe() threw exception TypeError: Not enough arguments.
 PASS observer.observe("mark") threw exception TypeError: Type error.
-PASS observer.observe({}) threw exception TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence.
+PASS observer.observe({}) threw exception TypeError: no type or entryTypes were provided.
 PASS observer.observe({entryTypes:"mark"}) threw exception TypeError: Value is not a sequence.
-PASS observer.observe({entryTypes:[]}) threw exception TypeError: entryTypes cannot be an empty list.
-PASS observer.observe({entryTypes:["not-real"]}) threw exception TypeError: entryTypes contained only unsupported types.
+PASS observer.observe({entryTypes:[]}) did not throw exception.
+PASS observer.observe({entryTypes:["not-real"]}) did not throw exception.
 PASS observer.observe({entryTypes:["mark"]}) did not throw exception.
 PASS observer.observe({entryTypes:["mark", "not-real"]}) did not throw exception.
 PASS observer.observe({entryTypes:["mark", "measure"]}) did not throw exception.
@@ -41,10 +41,10 @@
 PASS [Worker] observer = new PerformanceObserver(function() {}) did not throw exception.
 PASS [Worker] observer.observe() threw exception TypeError: Not enough arguments.
 PASS [Worker] observer.observe("mark") threw exception TypeError: Type error.
-PASS [Worker] observer.observe({}) threw exception TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence.
+PASS [Worker] observer.observe({}) threw exception TypeError: no type or entryTypes were provided.
 PASS [Worker] observer.observe({entryTypes:"mark"}) threw exception TypeError: Value is not a sequence.
-PASS [Worker] observer.observe({entryTypes:[]}) threw exception TypeError: entryTypes cannot be an empty list.
-PASS [Worker] observer.observe({entryTypes:["not-real"]}) threw exception TypeError: entryTypes contained only unsupported types.
+PASS [Worker] observer.observe({entryTypes:[]}) did not throw exception.
+PASS [Worker] observer.observe({entryTypes:["not-real"]}) did not throw exception.
 PASS [Worker] observer.observe({entryTypes:["mark"]}) did not throw exception.
 PASS [Worker] observer.observe({entryTypes:["mark", "not-real"]}) did not throw exception.
 PASS [Worker] observer.observe({entryTypes:["mark", "measure"]}) did not throw exception.

Modified: trunk/LayoutTests/performance-api/resources/observer-api.js (265000 => 265001)


--- trunk/LayoutTests/performance-api/resources/observer-api.js	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/LayoutTests/performance-api/resources/observer-api.js	2020-07-28 20:03:10 UTC (rev 265001)
@@ -16,8 +16,8 @@
 shouldThrow(`observer.observe("mark")`);
 shouldThrow(`observer.observe({})`);
 shouldThrow(`observer.observe({entryTypes:"mark"})`);
-shouldThrow(`observer.observe({entryTypes:[]})`);
-shouldThrow(`observer.observe({entryTypes:["not-real"]})`);
+shouldNotThrow(`observer.observe({entryTypes:[]})`);
+shouldNotThrow(`observer.observe({entryTypes:["not-real"]})`);
 shouldNotThrow(`observer.observe({entryTypes:["mark"]})`);
 shouldNotThrow(`observer.observe({entryTypes:["mark", "not-real"]})`);
 shouldNotThrow(`observer.observe({entryTypes:["mark", "measure"]})`);

Modified: trunk/Source/WebCore/ChangeLog (265000 => 265001)


--- trunk/Source/WebCore/ChangeLog	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/Source/WebCore/ChangeLog	2020-07-28 20:03:10 UTC (rev 265001)
@@ -1,3 +1,22 @@
+2020-07-28  Rob Buis  <rb...@igalia.com>
+
+        PerformanceObserver should work with 'type' and not just `entryTypes`
+        https://bugs.webkit.org/show_bug.cgi?id=209216
+
+        Reviewed by Youenn Fablet.
+
+        Add support for 'type' attribute as specified here [1].
+
+        Tests: imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.html
+               imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker.html
+
+        [1] https://w3c.github.io/performance-timeline/#dom-performanceobserverinit
+
+        * page/PerformanceObserver.cpp:
+        (WebCore::PerformanceObserver::observe):
+        * page/PerformanceObserver.h:
+        * page/PerformanceObserver.idl:
+
 2020-07-28  Karl Rackler  <rack...@apple.com>
 
         Unreviewed, reverting r264955.

Modified: trunk/Source/WebCore/page/PerformanceObserver.cpp (265000 => 265001)


--- trunk/Source/WebCore/page/PerformanceObserver.cpp	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/Source/WebCore/page/PerformanceObserver.cpp	2020-07-28 20:03:10 UTC (rev 265001)
@@ -60,18 +60,25 @@
     if (!m_performance)
         return Exception { TypeError };
 
-    if (init.entryTypes.isEmpty())
-        return Exception { TypeError, "entryTypes cannot be an empty list"_s };
-
     OptionSet<PerformanceEntry::Type> filter;
-    for (const String& entryType : init.entryTypes) {
-        if (auto type = PerformanceEntry::parseEntryTypeString(entryType))
+    if (init.entryTypes) {
+        if (init.type)
+            return Exception { TypeError, "either entryTypes or type must be provided"_s };
+        for (auto& entryType : *init.entryTypes) {
+            if (auto type = PerformanceEntry::parseEntryTypeString(entryType))
+                filter.add(*type);
+        }
+        if (filter.isEmpty())
+            return { };
+    } else {
+        if (!init.type)
+            return Exception { TypeError, "no type or entryTypes were provided"_s };
+        if (auto type = PerformanceEntry::parseEntryTypeString(*init.type))
             filter.add(*type);
+        else
+            return { };
     }
 
-    if (filter.isEmpty())
-        return Exception { TypeError, "entryTypes contained only unsupported types"_s };
-
     m_typeFilter = filter;
 
     if (!m_registered) {

Modified: trunk/Source/WebCore/page/PerformanceObserver.h (265000 => 265001)


--- trunk/Source/WebCore/page/PerformanceObserver.h	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/Source/WebCore/page/PerformanceObserver.h	2020-07-28 20:03:10 UTC (rev 265001)
@@ -41,7 +41,8 @@
 class PerformanceObserver : public RefCounted<PerformanceObserver> {
 public:
     struct Init {
-        Vector<String> entryTypes;
+        Optional<Vector<String>> entryTypes;
+        Optional<String> type;
     };
 
     static Ref<PerformanceObserver> create(ScriptExecutionContext& context, Ref<PerformanceObserverCallback>&& callback)

Modified: trunk/Source/WebCore/page/PerformanceObserver.idl (265000 => 265001)


--- trunk/Source/WebCore/page/PerformanceObserver.idl	2020-07-28 19:28:16 UTC (rev 265000)
+++ trunk/Source/WebCore/page/PerformanceObserver.idl	2020-07-28 20:03:10 UTC (rev 265001)
@@ -40,5 +40,6 @@
 };
 
 dictionary PerformanceObserverInit {
-    required sequence<DOMString> entryTypes;
+    sequence<DOMString> entryTypes;
+    DOMString type;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to