Title: [265281] trunk
Revision
265281
Author
[email protected]
Date
2020-08-05 01:22:02 -0700 (Wed, 05 Aug 2020)

Log Message

Allow multiple calls to PerformanceObserver.observe with different types
https://bugs.webkit.org/show_bug.cgi?id=214884

Patch by Rob Buis <[email protected]> on 2020-08-05
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Update improved test expectations.

* web-platform-tests/performance-timeline/po-observe-type.any-expected.txt:
* web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt:

Source/WebCore:

Allow multiple calls to PerformanceObserver.observe with different type, but
throw an exception if the observer type is changed [1].

Behavior matches Firefox and Chrome.

Test: imported/web-platform-tests/performance-timeline/po-observe-type.any.html

[1] https://w3c.github.io/performance-timeline/#observe-method

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

LayoutTests:

Unskip po-observe-type.any.html.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265280 => 265281)


--- trunk/LayoutTests/ChangeLog	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/LayoutTests/ChangeLog	2020-08-05 08:22:02 UTC (rev 265281)
@@ -1,3 +1,14 @@
+2020-08-05  Rob Buis  <[email protected]>
+
+        Allow multiple calls to PerformanceObserver.observe with different types
+        https://bugs.webkit.org/show_bug.cgi?id=214884
+
+        Reviewed by Darin Adler.
+
+        Unskip po-observe-type.any.html.
+
+        * TestExpectations:
+
 2020-08-04  Andres Gonzalez  <[email protected]>
 
         Disable isolated-tree-mode-on-off.html because it is causing other test failures..

Modified: trunk/LayoutTests/TestExpectations (265280 => 265281)


--- trunk/LayoutTests/TestExpectations	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/LayoutTests/TestExpectations	2020-08-05 08:22:02 UTC (rev 265281)
@@ -4516,8 +4516,6 @@
 # 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 ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265280 => 265281)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-05 08:22:02 UTC (rev 265281)
@@ -1,3 +1,15 @@
+2020-08-05  Rob Buis  <[email protected]>
+
+        Allow multiple calls to PerformanceObserver.observe with different types
+        https://bugs.webkit.org/show_bug.cgi?id=214884
+
+        Reviewed by Darin Adler.
+
+        Update improved test expectations.
+
+        * web-platform-tests/performance-timeline/po-observe-type.any-expected.txt:
+        * web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt:
+
 2020-08-04  Chris Dumez  <[email protected]>
 
         Align AudioListener with the W3C specification

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any-expected.txt (265280 => 265281)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any-expected.txt	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any-expected.txt	2020-08-05 08:22:02 UTC (rev 265281)
@@ -1,14 +1,8 @@
 
-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 entryTypes and then type should throw an InvalidModificationError 
+PASS Calling observe() with type and then entryTypes should throw an InvalidModificationError 
 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
+PASS observe() with different type values stacks. 
 

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/performance-timeline/po-observe-type.any.worker-expected.txt	2020-08-05 08:22:02 UTC (rev 265281)
@@ -1,14 +1,8 @@
 
-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 entryTypes and then type should throw an InvalidModificationError 
+PASS Calling observe() with type and then entryTypes should throw an InvalidModificationError 
 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
+PASS observe() with different type values stacks. 
 

Modified: trunk/Source/WebCore/ChangeLog (265280 => 265281)


--- trunk/Source/WebCore/ChangeLog	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/Source/WebCore/ChangeLog	2020-08-05 08:22:02 UTC (rev 265281)
@@ -1,3 +1,23 @@
+2020-08-05  Rob Buis  <[email protected]>
+
+        Allow multiple calls to PerformanceObserver.observe with different types
+        https://bugs.webkit.org/show_bug.cgi?id=214884
+
+        Reviewed by Darin Adler.
+
+        Allow multiple calls to PerformanceObserver.observe with different type, but
+        throw an exception if the observer type is changed [1].
+
+        Behavior matches Firefox and Chrome.
+
+        Test: imported/web-platform-tests/performance-timeline/po-observe-type.any.html
+
+        [1] https://w3c.github.io/performance-timeline/#observe-method
+
+        * page/PerformanceObserver.cpp:
+        (WebCore::PerformanceObserver::observe):
+        * page/PerformanceObserver.h:
+
 2020-08-05  Youenn Fablet  <[email protected]>
 
         Update AudioSampleDataSource offset computation

Modified: trunk/Source/WebCore/page/PerformanceObserver.cpp (265280 => 265281)


--- trunk/Source/WebCore/page/PerformanceObserver.cpp	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/Source/WebCore/page/PerformanceObserver.cpp	2020-08-05 08:22:02 UTC (rev 265281)
@@ -64,6 +64,8 @@
     if (init.entryTypes) {
         if (init.type)
             return Exception { TypeError, "either entryTypes or type must be provided"_s };
+        if (m_registered && m_isTypeObserver)
+            return Exception { InvalidModificationError, "observer type can't be changed once registered"_s };
         for (auto& entryType : *init.entryTypes) {
             if (auto type = PerformanceEntry::parseEntryTypeString(entryType))
                 filter.add(*type);
@@ -70,17 +72,20 @@
         }
         if (filter.isEmpty())
             return { };
+        m_typeFilter = filter;
     } else {
         if (!init.type)
             return Exception { TypeError, "no type or entryTypes were provided"_s };
+        if (m_registered && !m_isTypeObserver)
+            return Exception { InvalidModificationError, "observer type can't be changed once registered"_s };
+        m_isTypeObserver = true;
         if (auto type = PerformanceEntry::parseEntryTypeString(*init.type))
             filter.add(*type);
         else
             return { };
+        m_typeFilter.add(filter);
     }
 
-    m_typeFilter = filter;
-
     if (!m_registered) {
         m_performance->registerPerformanceObserver(*this);
         m_registered = true;

Modified: trunk/Source/WebCore/page/PerformanceObserver.h (265280 => 265281)


--- trunk/Source/WebCore/page/PerformanceObserver.h	2020-08-05 08:11:50 UTC (rev 265280)
+++ trunk/Source/WebCore/page/PerformanceObserver.h	2020-08-05 08:22:02 UTC (rev 265281)
@@ -73,6 +73,7 @@
     Ref<PerformanceObserverCallback> m_callback;
     OptionSet<PerformanceEntry::Type> m_typeFilter;
     bool m_registered { false };
+    bool m_isTypeObserver { false };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to