E540 script: Implement `DocumentOrShadowDOM.adoptedStylesheet` with `FrozenArray` by stevennovaryo · Pull Request #38163 · servo/servo · GitHub
[go: up one dir, main page]

Skip to content

Conversation

stevennovaryo
Copy link
Contributor
@stevennovaryo stevennovaryo commented Jul 18, 2025

Spec: https://drafts.csswg.org/cssom/#dom-documentorshadowroot-adoptedstylesheets

Implement DocumentOrShadowDOM.adoptedStylesheet. Due to ObservableArray being a massive issue on its own, it will be as it was a FrozenArray at first. This approach is similar to how Gecko implement adopted stylesheet. See https://phabricator.services.mozilla.com/D144547#change-IXyOzxxFn8sU.

All of the changes will be gated behind a preference dom_adoptedstylesheet_enabled.

Adopted stylesheet is implemented by adding the setter and getter of it. While the getter works like a normal attribute getter, the setter need to consider the inner working of document and shadow root StylesheetSet, specifically the ordering and the invalidations. Particularly for setter, we will clear all of the adopted stylesheet within the StylesheetSet and readd them. Possible optimization exist, but the focus should be directed to implementing ObservableArray.

More context about the implementations https://hackmd.io/vtJAn4UyS_O0Idvk5dCO_w.

Testing: Existing WPT Coverage
Fixes: #37561

@stevennovaryo stevennovaryo added the T-linux-wpt Do a try run of the WPT label Jul 18, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label Jul 18, 2025
Copy link

🔨 Triggering try run (#16366690888) for Linux (WPT)

Copy link

Test results for linux-wpt from try job (#16366690888):

Flaky unexpected result (11)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window_resize_event.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 20deg' should prefer 'oblique 10deg' over 'oblique 0deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 0deg' should prefer 'oblique -50deg -20deg' over 'oblique -40deg -30deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • OK /fetch/content-length/api-and-duplicate-headers.any.worker.html (#35197)
    • FAIL [expected PASS] subtest: fetch() and duplicate Content-Length/Content-Type headers

      promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"
      

  • OK /fetch/metadata/generated/css-font-face.sub.tentative.html (#34624)
    • FAIL [expected PASS] subtest: sec-fetch-storage-access - Not sent to non-trustworthy same-site destination

      promise_test: Unhandled rejection with value: object "Error: Failed to query for recorded headers."
      

  • ERROR /fetch/metadata/generated/serviceworker.https.sub.html (#36247)
    • PASS [expected FAIL] subtest: sec-fetch-site - Same origin, no options - registration
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.html (#29056)
    • PASS [expected FAIL] subtest: Cross-origin navigation started from unload handler must be ignored
  • PASS [expected FAIL] /html/canvas/element/manual/drawing-text-to-the-canvas/canvas.2d.disconnected-font-size-math.html (#30063)
  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/update-the-rendering.html (#24145)
    • TIMEOUT [expected FAIL] subtest: "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks

      Test timed out
      

  • OK /html/semantics/embedded-content/the-video-element/intrinsic_sizes.htm (#37173)
    • FAIL [expected PASS] subtest: default object size after src is removed

      assert_equals: expected "300px" but got "320px"
      

  • OK [expected TIMEOUT] /html/semantics/forms/form-submission-0/reparent-form 8000 -during-planned-navigation-task.html (#29724)
    • PASS [expected TIMEOUT] subtest: reparent-form-during-planned-navigation-task
  • ERROR [expected OK] /workers/constructors/Worker/Worker-constructor.html (#22991)
Stable unexpected results that are known to be intermittent (22)
  • TIMEOUT /FileAPI/url/url-in-tags-revoke.window.html (#19978)
    • TIMEOUT [expected PASS] subtest: Fetching a blob URL immediately before revoking it works in <script> tags.

      Test timed out
      

  • FAIL [expected PASS] /_mozilla/css/stacked_layers.html (#15988)
  • FAIL [expected PASS] /_mozilla/mozilla/sslfail.html (#10760)
  • FAIL [expected PASS] /css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html (#29187)
  • TIMEOUT [expected FAIL] /dom/xslt/large-cdata.html (#38029)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-dest
  • OK /html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html (#29066)
    • FAIL [expected PASS] subtest: Check execution order from nested timeout

      assert_equals: Expected nested setTimeout to run second expected true but got false
      

    • FAIL [expected PASS] subtest: Check execution order on load handler

      assert_equals: Expected onload to run first expected false but got true
      

  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-aboutblank-navigate-immediately.html (#29048)
    • FAIL [expected PASS] subtest: Navigating to a different document with location.href

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?1" but got "about:blank"
      

    • FAIL [expected PASS] subtest: Navigating to a different document with location.assign

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?1" but got "about:blank"
      

    • TIMEOUT [expected FAIL] subtest: Navigating to a different document with form submission

      Test timed out
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html (#28691)
    • FAIL [expected PASS] subtest: load event does not fire on window.open('about:blank')

      assert_unreached: load should not be fired Reached unreachable code
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • FAIL [expected PASS] subtest: Same-origin navigation started from unload handler must be ignored

      assert_equals: expected "?pass" but got "?fail"
      

  • FAIL [expected PASS] /html/canvas/element/manual/text/canvas.2d.disconnected.html (#30063)
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected NOTRUN] subtest: Host element with delegatesFocus including no focusable descendants should be skipped

      assert_equals: expected Element node <input autofocus=""></input> but got Element node <body></body>
      

    • FAIL [expected NOTRUN] subtest: Area element should support autofocus

      promise_test: Unhandled rejection with value: object "TypeError: w.document.querySelector(...) is null"
      

  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
    • FAIL [expected NOTRUN] subtest: Check that popups from a sandboxed iframe do not escape the sandbox

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • OK /html/semantics/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
    • PASS [expected FAIL] subtest: Verifies that location navigations take precedence when following form submissions.
  • OK /html/semantics/forms/historical.html (#28568)
    • FAIL [expected PASS] subtest: <input name=isindex> should not be supported

      assert_regexp_match: expected object "/\?isindex=x$/" but got "about:blank"
      

  • OK /navigation-timing/test-navigation-type-reload.html (#33334)
    • PASS [expected FAIL] subtest: Reload domInteractive > Original domInteractive
  • OK /preload/preload-error.sub.html (#37177)
    • FAIL [expected PASS] subtest: CORS (style): main

      assert_greater_than: http://not-web-platform.test:8000/preload/resources/dummy.css?pipe=header%28Access-Control-Allow-Origin%2C*%29&label=style should be loaded expected a number greater than 0 but got 0
      

    • FAIL [expected PASS] subtest: CORS (script): main

      assert_greater_than: http://not-web-platform.test:8000/preload/resources/dummy.js?pipe=header%28Access-Control-Allow-Origin%2C*%29&label=script should be loaded expected a number greater than 0 but got 0
      

    • FAIL [expected PASS] subtest: Decode-error (style): main

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.xml?pipe=header%28Content-Type%2Ctext%2Fcss%29&label=style should be loaded expected a number greater than 0 but got 0
      

    • FAIL [expected PASS] subtest: Decode-error (script): main

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.xml?pipe=header%28Content-Type%2Ctext%2Fjavascript%29&label=script should be loaded expected a number greater than 0 but got 0
      

  • TIMEOUT /preload/preload-resource-match.https.html (#38088)
    • FAIL [expected TIMEOUT] subtest: Loading script (anonymous) with link (no-cors) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&content=function%20dummy()%20%7B%20%7D&uid=d3332458-786e-49d7-bd32-57db1e835036&012a911b-bf3b-4080-a4c8-b868d63f11b0 expected 2 but got 1
      

    • PASS [expected NOTRUN] subtest: Loading script (anonymous) with link (anonymous) should reuse the preloaded response
    • FAIL [expected NOTRUN] subtest: Loading script (anonymous) with link (use-credentials) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&content=function%20dummy()%20%7B%20%7D&uid=d3332458-786e-49d7-bd32-57db1e835036&3a360684-dc44-4f1d-9fa1-167cf958c7af expected 2 but got 1
      

    • FAIL [expected NOTRUN] subtest: Loading script (use-credentials) with link (no-cors) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&content=function%20dummy()%20%7B%20%7D&uid=d3332458-786e-49d7-bd32-57db1e835036&6c21b86f-ea44-45c5-9110-8292aabced13 expected 2 but got 1
      

    • TIMEOUT [expected NOTRUN] subtest: Loading script (use-credentials) with link (anonymous) should discard the preloaded response

      Test timed out
      

  • TIMEOUT [expected OK] /webmessaging/with-ports/018.html (#24485)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, javascript:

      Test timed out
      

  • OK [expected ERROR] /webxr/render_state_update.https.html (#27535)
Stable unexpected results (8)
  • OK /css/css-cascade/layer-replaceSync-clears-stale.html
    • PASS [expected FAIL] subtest: replaceSync clears stale layer statements
  • PASS [expected TIMEOUT] /css/cssom/CSSStyleSheet-constructable-concat.html
  • OK /css/cssom/CSSStyleSheet-constructable-invalidation.html
    • PASS [expected FAIL] subtest: mutating constructed CSSStyleSheet applied to root invalidates styles
    • PASS [expected FAIL] subtest: mutating constructed CSSStyleSheet applied to shadowdom invalidates styles
    • PASS [expected FAIL] subtest: mutating dependent constructed CSSStyleSheet applied to shadowdom invalidates styles
  • OK /css/cssom/CSSStyleSheet-constructable.html
    • PASS [expected FAIL] subtest: document.adoptedStyleSheets should initially have length 0.
    • PASS [expected FAIL] subtest: Attaching a shadow root that already has adopted stylesheets work
    • PASS [expected FAIL] subtest: Re-attaching shadow host and updating attributes work
    • PASS [expected FAIL] subtest: Adding non-constructed stylesheet to AdoptedStyleSheets is not allowed when the owner document of the stylesheet is in the same document tree as the AdoptedStyleSheets
    • PASS [expected FAIL] subtest: Adding non-constructed stylesheet to AdoptedStyleSheets is not allowed when the owner document of the stylesheet and the AdoptedStyleSheets are in different document trees
  • OK /css/cssom/adoptedstylesheets-modify-array-and-sheet.html
    • PASS [expected FAIL] subtest: Add the two sheets. Text should be red.
    • PASS [expected FAIL] subtest: Flip the two sheet. Still red.
    • PASS [expected FAIL] subtest: Modify the color declaration. Should now be green.
  • OK /css/cssom/adoptedstylesheets-observablearray.html
    • PASS [expected FAIL] subtest: adoptedStyleSheets should return true for isArray()
  • OK /css/cssom/idlharness.html
    • PASS [expected FAIL] subtest: Document interface: attribute adoptedStyleSheets
    • PASS [expected FAIL] subtest: Document interface: document must inherit property "adoptedStyleSheets" with the proper type
    • PASS [expected FAIL] subtest: Document interface: new Document() must inherit property "adoptedStyleSheets" with the proper type
    • PASS [expected FAIL] subtest: ShadowRoot interface: attribute adoptedStyleSheets
  • OK /webidl/ecmascript-binding/observable-array-no-leak-of-internals.window.html
    • PASS [expected FAIL] subtest: ObservableArray's internals won't leak

Copy link
8000

⚠️ Try run (#16366690888) failed.

@stevennovaryo stevennovaryo force-pushed the impl-adopted-stylesheet branch from 08249d3 to 628030a Compare July 18, 2025 09:41
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
@stevennovaryo stevennovaryo force-pushed the impl-adopted-stylesheet branch from 628030a to f76e235 Compare July 18, 2025 10:10
@stevennovaryo stevennovaryo added the T-linux-wpt Do a try run of the WPT label Jul 18, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label Jul 18, 2025
Copy link

🔨 Triggering try run (#16370133621) for Linux (WPT)

Copy link

Test results for linux-wpt from try job (#16370133621):

Flaky unexpected result (20)
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • PASS [expected FAIL] subtest: WebGL test #61
    • PASS [expected FAIL] subtest: WebGL test #63
    • PASS [expected FAIL] subtest: WebGL test #65
    • PASS [expected FAIL] subtest: WebGL test #67
  • OK /content-security-policy/frame-ancestors/frame-ancestors-path-ignored.window.html (#36468)
    • PASS [expected FAIL] subtest: A 'frame-ancestors' CSP directive with a URL that includes a path should be ignored.
  • OK /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
    • PASS [expected FAIL] subtest: Link with onclick navigation and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/008.html (#24456)
    • PASS [expected FAIL] subtest: Link with onclick form submit to javascript url and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-nosrc.html (#34819)
    • PASS [expected FAIL] subtest: link click
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin-fragment.html (#20768)
    • FAIL [expected PASS] subtest: Tests that a fragment navigation in the unload handler will not block the initial navigation

      assert_equals: expected "" but got "#fragment"
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • PASS [expected FAIL] subtest: aElement.click() before the load event must NOT replace
  • OK /html/browsers/windows/browsing-context-names/duplicate-name-order.html (#34623)
    • PASS [expected FAIL] subtest: Duplicate name lookup order
  • TIMEOUT [expected OK] /html/infrastructure/urls/base-url/document-base-url-window-initiator-is-not-opener.https.window.html (#30970)
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
  • OK /html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.worker.html (#33909)
    • FAIL [expected PASS] subtest: Revoking a blob URL immediately after calling import will not fail

      promise_test: Unhandled rejection with value: object "TypeError: Dynamic import failed"
      

  • OK /navigation-timing/test-navigation-type-reload.html (#33334)
    • PASS [expected FAIL] subtest: Reload domComplete &gt; Original domComplete
    • PASS [expected FAIL] subtest: Reload domContentLoadedEventEnd &gt; Original domContentLoadedEventEnd
    • PASS [expected FAIL] subtest: Reload domContentLoadedEventStart &gt; Original domContentLoadedEventStart
    • PASS [expected FAIL] subtest: Reload fetchStart &gt; Original fetchStart
    • PASS [expected FAIL] subtest: Reload loadEventEnd &gt; Original loadEventEnd
    • PASS [expected FAIL] subtest: Reload loadEventStart &gt; Original loadEventStart
  • OK /preload/prefetch-document.html (#37210)
    • FAIL [expected PASS] subtest: different-site document prefetch with 'as=document' should not be consumed

      assert_equals: expected 2 but got 1
      

  • OK /resize-observer/eventloop.html (#33599)
    • FAIL [expected PASS] subtest: test0: multiple notifications inside same event loop

      assert_equals: new loop expected 1 but got 0
      

  • TIMEOUT /resource-timing/test_resource_timing.html (#25720)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (img)
  • TIMEOUT /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (img)
  • TIMEOUT [expected CRASH] /trusted-types/trusted-types-navigation.html?06-10 (#37920)
  • TIMEOUT [expected CRASH] /trusted-types/trusted-types-navigation.html?31-35 (#38034)
    • FAIL [expected PASS] subtest: Navigate a frame via form-submission with javascript:-urls in report-only mode.

      promise_test: Unhandled rejection with value: "Unexpected message received: \"No securitypolicyviolation reported!\""
      

    • TIMEOUT [expected PASS] subtest: Navigate a frame via form-submission with javascript:-urls w/ default policy in report-only mode.

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Navigate a window via form-submission with javascript:-urls w/ a default policy throwing an exception in enforcing mode.
    • NOTRUN [expected PASS] subtest: Navigate a window via form-submission with javascript:-urls w/ a default policy throwing an exception in report-only mode.
    • NOTRUN [expected PASS] subtest: Navigate a window via form-submission with javascript:-urls w/ a default policy making the URL invalid in enforcing mode.
  • OK [expected TIMEOUT] /webmessaging/without-ports/017.html (#24486)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, about:blank
  • OK /xhr/send-redirect.htm (#32026)
    • FAIL [expected PASS] subtest: XMLHttpRequest: send() - Redirects (basics) (302, GET, content.py)

      assert_equals: expected (string) "GET" but got (object) null
      

Stable unexpected results that are known to be intermittent (20)
  • FAIL [expected PASS] /_mozilla/css/stacked_layers.html (#15988)
  • FAIL [expected PASS] /_mozilla/mozilla/sslfail.html (#10760)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window_resize_event.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '501' should prefer '390 410' over '300 350'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-weight: '399' should prefer '200 300' over '400'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • PASS [expected FAIL] subtest: Matching font-style: 'oblique -20deg' should prefer 'oblique 40deg 50deg' over 'italic'
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique -21deg' should prefer 'oblique -10deg' over 'oblique 0deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • FAIL [expected PASS] /css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html (#29187)
  • TIMEOUT [expected FAIL] /dom/xslt/large-cdata.html (#38029)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-user
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Same site
  • OK /fetch/metadata/generated/css-font-face.sub.tentative.html (#34624)
    • FAIL [expected PASS] subtest: sec-fetch-storage-access - Not sent to non-trustworthy same-site destination

      promise_test: Unhandled rejection with value: object "Error: Failed to query for recorded headers."
      

    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Not sent to non-trustworthy cross-site destination
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (#28681)
    • PASS [expected FAIL] subtest: load &amp; pageshow events do not fire on contentWindow of &lt;iframe&gt; element created with src='about:blank'
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • FAIL [expected PASS] subtest: Same-origin navigation started from unload handler must be ignored

      assert_equals: expected "?pass" but got "?fail"
      

  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • PASS [expected FAIL] subtest: traversing history must also traverse hash changes
  • TIMEOUT /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • TIMEOUT [expected PASS] subtest: Non-HTMLElement should not support autofocus

      Test timed out
      

    • NOTRUN [expected FAIL] subtest: Host element with delegatesFocus should support autofocus
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html (#24066)
    • NOTRUN [expected FAIL] subtest: Check that popups from a sandboxed iframe do not escape the sandbox
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • OK [expected TIMEOUT] /html/semantics/forms/form-submission-0/reparent-form-during-planned-navigation-task.html (#29724)
    • PASS [expected TIMEOUT] subtest: reparent-form-during-planned-navigation-task
  • OK /preload/preload-error.sub.html (#37177)
    • PASS [expected FAIL] subtest: 404 (style): main
    • PASS [expected FAIL] subtest: success (xhr): main
    • FAIL [expected PASS] subtest: Decode-error (style): main

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.xml?pipe=header%28Content-Type%2Ctext%2Fcss%29&amp;label=style should be loaded expected a number greater than 0 but got 0
      

  • TIMEOUT /preload/preload-resource-match.https.html (#38088)
    • FAIL [expected TIMEOUT] subtest: Loading script (anonymous) with link (no-cors) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&amp;content=function%20dummy()%20%7B%20%7D&amp;uid=c4d82108-98d4-4b74-9f4d-2a3c679c5d10&amp;e0ab7993-8424-4cb0-900f-9c9c46ff4a1e expected 2 but got 1
      

    • PASS [expected NOTRUN] subtest: Loading script (anonymous) with link (anonymous) should reuse the preloaded response
    • FAIL [expected NOTRUN] subtest: Loading script (anonymous) with link (use-credentials) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&amp;content=function%20dummy()%20%7B%20%7D&amp;uid=c4d82108-98d4-4b74-9f4d-2a3c679c5d10&amp;bc3e9104-d658-4ee7-bc9c-faca8c7c542a expected 2 but got 1
      

    • TIMEOUT [expected NOTRUN] subtest: Loading script (use-credentials) with link (no-cors) should discard the preloaded response

      Test timed out
      

  • TIMEOUT [expected OK] /webmessaging/with-ports/018.html (#24485)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, javascript:

      Test timed out
      

  • OK [expected TIMEOUT] /webmessaging/without-ports/018.html (#24485)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, javascript:
  • OK [expected ERROR] /webxr/render_state_update.https.html (#27535)

Copy link

✨ Try run (#16370133621) succeeded.

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
@stevennovaryo stevennovaryo force-pushed the impl-adopted-stylesheet branch from 19cf9bc to 3bfeb66 Compare July 19, 2025 05:38
@stevennovaryo stevennovaryo marked this pull request as ready for review July 19, 2025 05:38
@stevennovaryo stevennovaryo requested a review from gterzian as a code owner July 19, 2025 05:38
Copy link
Contributor
@xiaochengh xiaochengh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general! There are some more detailed comments.

// The idea is that this case is rare, so we pay the price of removing the
// old sheet from the styles and append it later rather than the other way
// around.
owner.remove_stylesheet(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should deduplicate sheets here. There are cases where:

  • The sheet list is [A, B, A]
  • We should keep both A. If we keep only one of them, the cascade result is wrong

Example here: https://github.com/web-platform-tests/wpt/blob/master/css/css-cascade/layer-stylesheet-sharing.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU the case is a little bit different. For this case, we are having two different Stylesheet parsed from a same Stylesheet.

Not sure what is the full implication, but Stylo is preventing us from having duplicate Stylesheet inside a StylesheetSet. I believe it would be fine as long as we are keeping the last occurrence duplicates here, which is what Gecko does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to replicate it with adoptedStylesheets. It seems that Blink is keeping the first one while Gecko is keeping the last one, and both are wrong.

So to make things correct, we must keep both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is the full implication, but Stylo is preventing us from having duplicate Stylesheet inside a StylesheetSet.

Hmm, this sounds tricky. Let's file a bug to Stylo and add a TODO to this part then.

Copy link
Contributor Author
@stevennovaryo stevennovaryo Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this sounds tricky. Let's file a bug to Stylo and add a TODO to this part then.

Added a TODO here. I am looking for relevant issues, as it was a design used by Gecko, it should be filed to Bugzilla as well.

The concern could be handled other PRs, step by step. As it was a preference gated feature.

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
@stevennovaryo stevennovaryo force-pushed the impl-adopted-stylesheet branch from 3fe0b08 to 0301d21 Compare July 21, 2025 09:36
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
@stevennovaryo stevennovaryo force-pushed the impl-adopted-stylesheet branch from 0301d21 to 3e0c7fb Compare July 21, 2025 09:51
@stevennovaryo stevennovaryo added the T-linux-wpt Do a try run of the WPT label Jul 21, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label Jul 21, 2025
Copy link

🔨 Triggering try run (#16413847402) for Linux (WPT)

@stevennovaryo stevennovaryo requested a review from xiaochengh July 21, 2025 09:55
Copy link

Test results for linux-wpt from try job (#16413847402):

Flaky unexpected result (19)
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique -21deg' should prefer 'oblique -60deg -40deg' over 'oblique -10deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • OK /css/css-values/calc-size/calc-size-flex-basis-on-row.html
    • FAIL [expected PASS] subtest: resolved value for width resulting from flex-basis: min-content

      assert_equals: resulting width is correct expected "400px" but got "218px"
      

    • FAIL [expected PASS] subtest: resolved value for width resulting from flex-basis: fit-content

      assert_equals: resulting width is correct expected "500px" but got "324px"
      

    • FAIL [expected PASS] subtest: resolved value for width resulting from flex-basis: max-content

      assert_equals: resulting width is correct expected "600px" but got "324px"
      

    • FAIL [expected PASS] subtest: resolved value for width resulting from flex-basis: content

      assert_equals: resulting width is correct expected "600px" but got "324px"
      

    • FAIL [expected PASS] subtest: resolved value for width resulting from flex-basis: auto and width: auto

      assert_equals: resulting width is correct expected "600px" but got "324px"
      

  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Same site
  • OK /html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html (#29066)
    • FAIL [expected PASS] subtest: Check execution order from nested timeout

      assert_equals: Expected nested setTimeout to run second expected true but got false
      

    • FAIL [expected PASS] subtest: Check execution order on load handler

      assert_equals: Expected onload to run first expected false but got true
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html (#28691)
    • FAIL [expected PASS] subtest: load event does not fire on window.open('about:blank')

      assert_unreached: load should not be fired Reached unreachable code
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • PASS [expected FAIL] subtest: aElement.click() before the load event must NOT replace
  • OK /html/browsers/history/the-history-interface/traverse_the_history_4.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • OK /html/browsers/windows/browsing-context-names/duplicate-name-order.html (#34623)
    • PASS [expected FAIL] subtest: Duplicate name lookup order
  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/autofocus-dialog.html (#29087)
    • TIMEOUT [expected FAIL] subtest: &lt;dialog&gt;-contained autofocus element gets focused when the dialog is shown

      Test timed out
      

  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/document-with-fragment-empty.html (#28259)
    • TIMEOUT [expected FAIL] subtest: Autofocus elements in top-level browsing context's documents with empty fragments should work.

      Test timed out
      

  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/document-with-fragment-top.html (#28259)
    • TIMEOUT [expected FAIL] subtest: Autofocus elements in top-level browsing context's documents with "top" fragments should work.

      Test timed out
      

  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html (#24066)
    • NOTRUN [expected FAIL] subtest: Check that popups from a sandboxed iframe do not escape the sandbox
  • OK /navigation-timing/test-navigation-type-reload.html (#33334)
    • PASS [expected FAIL] subtest: Reload domComplete &gt; Original domComplete
    • PASS [expected FAIL] subtest: Reload domContentLoadedEventEnd &gt; Original domContentLoadedEventEnd
    • PASS [expected FAIL] subtest: Reload domContentLoadedEventStart &gt; Original domContentLoadedEventStart
    • PASS [expected FAIL] subtest: Reload fetchStart &gt; Original fetchStart
    • PASS [expected FAIL] subtest: Reload loadEventEnd &gt; Original loadEventEnd
    • PASS [expected FAIL] subtest: Reload loadEventStart &gt; Original loadEventStart
  • OK /preload/prefetch-document.html (#37210)
    • FAIL [expected PASS] subtest: different-site document prefetch with 'as=document' should not be consumed

      assert_equals: expected 2 but got 1
      

  • OK [expected TIMEOUT] /webmessaging/without-ports/017.html (#24486)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, about:blank
  • OK [expected TIMEOUT] /webmessaging/without-ports/018.html (#24485)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, javascript:
  • OK [expected ERROR] /webxr/render_state_update.https.html (#27535)
  • ERROR [expected OK] /workers/constructors/Worker/Worker-constructor.html (#22991)
Stable unexpected results that are known to be intermittent (19)
  • FAIL [expected PASS] /_mozilla/css/stacked_layers.html (#15988)
  • FAIL [expected PASS] /_mozilla/mozilla/sslfail.html (#10760)
  • FAIL [expected PASS] /css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html (#29187)
  • TIMEOUT [expected FAIL] /dom/xslt/large-cdata.html (#38029)
  • ERROR [expected TIMEOUT] /fetch/fetch-later/quota/same-origin-iframe/max-payload.tentative.https.window.html (#35210)
  • OK [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/multiple-iframes.tentative.https.window.html (#35176)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/009.html (#24456)
    • PASS [expected FAIL] subtest: Link with onclick form submit to javascript url with document.write and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (#28681)
    • PASS [expected FAIL] subtest: load &amp; pageshow events do not fire on contentWindow of &lt;iframe&gt; element created with src='about:blank'
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • FAIL [expected PASS] subtest: Same-origin navigation started from unload handler must be ignored

      assert_equals: expected "?pass" but got "?fail"
      

  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • PASS [expected FAIL] subtest: traversing history must also traverse hash changes
  • FAIL [expected PASS] /html/canvas/element/manual/text/canvas.2d.disconnected.html (#30063)
  • TIMEOUT /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • TIMEOUT [expected FAIL] subtest: Host element with delegatesFocus should support autofocus

      Test timed out
      

  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/update-the-rendering.html (#24145)
    • TIMEOUT [expected FAIL] subtest: "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks

      Test timed out
      

  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
    • FAIL [expected NOTRUN] subtest: Check that popups from a sandboxed iframe do not escape the sandbox

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • OK /html/semantics/forms/historical.html (#28568)
    • FAIL [expected PASS] subtest: &lt;input name=isindex&gt; should not be supported

      assert_regexp_match: expected object "/\?isindex=x$/" but got "about:blank"
      

  • OK /preload/preload-error.sub.html (#37177)
    • FAIL [expected PASS] subtest: CORS (style): main

      assert_greater_than: http://not-web-platform.test:8000/preload/resources/dummy.css?pipe=header%28Access-Control-Allow-Origin%2C*%29&amp;label=style should be loaded expected a number greater than 0 but got 0
      

    • PASS [expected FAIL] subtest: success (script): main
    • PASS [expected FAIL] subtest: 404 (script): main
  • TIMEOUT /preload/preload-resource-match.https.html (#38088)
    • FAIL [expected TIMEOUT] subtest: Loading script (anonymous) with link (no-cors) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&amp;content=function%20dummy()%20%7B%20%7D&amp;uid=f1d169e6-fab7-46d3-85c0-5bb18487fd0e&amp;3e78ba8b-dcd5-4f9b-a1fa-ded3daf55472 expected 2 but got 1
      

    • PASS [expected NOTRUN] subtest: Loading script (anonymous) with link (anonymous) should reuse the preloaded response
    • FAIL [expected NOTRUN] subtest: Loading script (anonymous) with link (use-credentials) should discard the preloaded response

      assert_equals: https://www1.web-platform.test:8443/preload/resources/echo-with-cors.py?type=application%2Fjavascript&amp;content=function%20dummy()%20%7B%20%7D&amp;uid=f1d169e6-fab7-46d3-85c0-5bb18487fd0e&amp;43287376-3766-44db-882b-16b4c14c3fe4 expected 2 but got 1
      

    • TIMEOUT [expected NOTRUN] subtest: Loading script (use-credentials) with link (no-cors) should discard the preloaded response

      Test timed out
      

  • TIMEOUT [expected OK] /resource-timing/tentative/document-initiated.html (#37785)
  • ERROR /service-workers/idlharness.https.any.html (#36250)
    • PASS [expected TIMEOUT] subtest: ServiceWorkerContainer interface: operation register((TrustedScriptURL or USVString), optional RegistrationOptions)
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation enable()
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation disable()
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation setHeaderValue(ByteString)
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation getState()

Copy link

✨ Try run (#16413847402) succeeded.

@mrobinson mrobinson changed the title script: Impl DocumentOrShadorDOM.adoptedStylesheet with FrozenArray script: Implement DocumentOrShadorDOM.adoptedStylesheet with FrozenArray Jul 23, 2025
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
@stevennovaryo stevennovaryo changed the title script: Implement DocumentOrShadorDOM.adoptedStylesheet with FrozenArray script: Implement DocumentOrShadowDOM.adoptedStylesheet with FrozenArray Jul 23, 2025
@xiaochengh xiaochengh enabled auto-merge July 23, 2025 07:44
@xiaochengh xiaochengh added this pull request to the merge queue Jul 23, 2025
Merged via the queue into servo:main with commit f523445 Jul 23, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Implement Document/ShadowRoot.adoptedStylesheets
2 participants
0