Skip to content

script: Implement CSSStyleSheet.replace - #38244

Merged
jdm merged 3 commits into
servo:mainfrom
stevennovaryo:cssstylesheet-replace
Jul 25, 2025
Merged

jdm merged 3 commits into
servo:mainfrom
stevennovaryo:cssstylesheet-replace

Conversation

@stevennovaryo

@stevennovaryo stevennovaryo commented Jul 23, 2025 •

Copy link
Copy Markdown
Member

Implement CSSStyleSheet.replace #dom-cssstylesheet-replace with disallow modification flag #concept-css-style-sheet-disallow-modification-flag.

Basically it would behave like replaceSync, but we are running it asynchronously.

Testing: Existing WPT coverage.
Part of: #36162

Signed-off-by: Jo Steven Novaryo <[email protected]>
@stevennovaryo
stevennovaryo requested a review from gterzian as a code owner July 23, 2025 19:50
@stevennovaryo stevennovaryo added the T-linux-wpt Do a try run of the WPT label Jul 23, 2025
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Jul 23, 2025
@github-actions

Copy link
Copy Markdown

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

@stevennovaryo stevennovaryo changed the title script: implement CSSStyleSheet.replace script: Implement CSSStyleSheet.replace Jul 23, 2025
@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (16)
  • FAIL [expected PASS] /_mozilla/css/dirty_viewport.html (#13731)
  • FAIL [expected PASS] /_mozilla/css/iframe/hide_and_show.html (#15265)
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '430' should prefer '420 440' over '450 460'

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

  • OK /fetch/metadata/generated/css-font-face.sub.tentative.html (#34624)
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Not sent to non-trustworthy same-origin destination
    • 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/005.html (#27062)
    • PASS [expected FAIL] subtest: Link with onclick navigation 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/initial-empty-document/iframe-src-aboutblank-navigate-immediately.html (#29048)
    • PASS [expected FAIL] subtest: Navigating to a different document with link click
  • OK /html/browsers/history/the-history-interface/traverse_the_history_3.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • CRASH [expected OK] /html/browsers/the-window-object/open-close/open-features-non-integer-left.html
  • 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
      

  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
  • 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
      

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

      Test timed out
      

    • NOTRUN [expected TIMEOUT] subtest: Loading script (use-credentials) with link (anonymous) should discard the preloaded response
  • TIMEOUT [expected OK] /resource-timing/nested-context-navigations-iframe.html (#24311)
    • TIMEOUT [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent, even after history navigations by the parent

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Test that iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe refreshes are not observable by the parent
  • 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/open-url-multi-window-5.htm (#23360)
    • FAIL [expected PASS] subtest: XMLHttpRequest: open() resolving URLs (multi-Window; 5)

      assert_throws_dom: function "function() {client.open("GET", "...") }" did not throw
      

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 /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #53

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #55

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #57

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #59

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • 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
    • FAIL [expected PASS] subtest: WebGL test #69

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #71

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • And 2 more unexpected results...
  • FAIL [expected PASS] /css/css-sizing/dynamic-available-size-iframe.html (#31559)
  • TIMEOUT [expected FAIL] /dom/xslt/large-cdata.html (#38029)
  • TIMEOUT [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/max-payload.tentative.https.window.html (#35210)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-dest
  • OK /html/browsers/history/the-history-interface/traverse_the_history_4.html (#21383)
    • FAIL [expected PASS] subtest: Multiple history traversals, last would be aborted

      assert_array_equals: Pages opened during history navigation expected property 1 to be 5 but got 3 (expected array [6, 5] got [6, 3])
      

  • 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 &lt;input autofocus=""&gt;&lt;/input&gt; but got Element node &lt;body&gt;&lt;div autofocus=""&gt;&lt;/div&gt;&lt;input autofocus=""&gt;&lt;/body&gt;
      

    • 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)
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html (#24057)
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • 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 [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 /navigation-timing/test-navigation-type-reload.html (#33334)
    • FAIL [expected PASS] subtest: Reload domComplete &gt; Original domComplete

      assert_true: Reload domComplete &gt; Original domComplete expected true got false
      

    • FAIL [expected PASS] subtest: Reload loadEventEnd &gt; Original loadEventEnd

      assert_true: Reload loadEventEnd &gt; Original loadEventEnd expected true got false
      

    • FAIL [expected PASS] subtest: Reload loadEventStart &gt; Original loadEventStart

      assert_true: Reload loadEventStart &gt; Original loadEventStart expected true got false
      

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

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.css?pipe=status%28404%29&amp;label=style should be loaded expected a number greater than 0 but got 0
      

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

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.js?pipe=status%28404%29&amp;label=script should be loaded expected a number greater than 0 but got 0
      

    • PASS [expected FAIL] subtest: 404 (xhr): main
    • 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&amp;label=script should be loaded expected a number greater than 0 but got 0
      

    • PASS [expected FAIL] subtest: MIME-error (script): main
  • OK /resize-observer/eventloop.html (#33599)
    • PASS [expected FAIL] subtest: test0: multiple notifications inside same event loop
  • OK [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?06-10 (#37920)
    • FAIL [expected TIMEOUT] subtest: Navigate a frame via anchor with javascript:-urls w/ default policy in report-only mode.

      promise_test: Unhandled rejection with value: "Unexpected message received: {\"type\":\"DOMContentLoaded\",\"uri\":\"http://web-platform.test:8000/trusted-types/support/navigation-support.html?defaultpolicy=replace&amp;frame=1&amp;navigationattempted=1&amp;continue=1\"}"
      

    • FAIL [expected NOTRUN] subtest: Navigate a window via anchor with javascript:-urls w/ a default policy throwing an exception in enforcing mode.

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

    • FAIL [expected NOTRUN] subtest: Navigate a window via anchor with javascript:-urls w/ a default policy throwing an exception in report-only mode.

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

  • OK /webaudio/the-audio-api/the-audiobuffersourcenode-interface/sub-sample-buffer-stitching.html (#22849)
    • FAIL [expected PASS] subtest: X Stitched sine-wave buffers at sample rate 43800 does not equal [0,0.06264832615852356,0.12505052983760834,0.18696144223213196,0.24813786149024963,0.308339387178421,0.36732959747314453,0.4248766601085663,0.480754554271698,0.5347436666488647,0.5866320133209229,0.6362156271934509,0.6832997798919678,0.7276994585990906,0.7692402601242065,0.8077589869499207...] with an element-wise tolerance of {"absoluteThreshold":0.0038986,"relativeThreshold":0}. Index Actual Expected AbsError RelError Test threshold [14620] -5.7182457796202227e+21 -7.3546999692916870e-1 5.7182457796202227e+21 7.7749545236322299e+21 3.8985999999999999e-3 [14621] -3.6017334461212158e-1 -6.9157749414443970e-1 3.3140414953231812e-1 4.7920030992665957e-1 3.8985999999999999e-3 Max AbsError of 5.7182457796202227e+21 at index of 14620. Max RelError of 7.7749545236322299e+21 at index of 14620.

      assert_true: expected true got false
      

    • FAIL [expected PASS] subtest: X SNR (-391.71117041825926 dB) is not greater than or equal to 65.737. Got -391.71117041825926.

      assert_true: expected true got false
      

Stable unexpected results (2)
  • OK /css/cssom/CSSStyleSheet-constructable.html
    • PASS [expected FAIL] subtest: Constructed style sheets can be applied on document
    • PASS [expected FAIL] subtest: CSSStyleSheet.replace does not reject on failed imports
  • OK /css/cssom/idlharness.html
    • PASS [expected FAIL] subtest: CSSStyleSheet interface: operation replace(USVString)
    • PASS [expected FAIL] subtest: CSSStyleSheet interface: sheet must inherit property "replace(USVString)" with the proper type
    • PASS [expected FAIL] subtest: CSSStyleSheet interface: calling replace(USVString) on sheet with too few arguments must throw TypeError

@github-actions

Copy link
Copy Markdown

⚠️ Try run (#16480424106) failed.

Comment thread components/script/dom/cssstylesheet.rs Outdated

/// <https://drafts.csswg.org/cssom/#synchronously-replace-the-rules-of-a-cssstylesheet>
fn ReplaceSync(&self, text: USVString) -> Result<(), Error> {
// Step 1. If the constructed flag is not set throw a NotAllowedError

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you update the text in this comment to match the spec?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I have updated it!

@stevennovaryo
stevennovaryo force-pushed the cssstylesheet-replace branch from 56804a4 to 5d22d07 Compare July 24, 2025 09:40
Signed-off-by: Jo Steven Novaryo <[email protected]>
@stevennovaryo
stevennovaryo force-pushed the cssstylesheet-replace branch from 5d22d07 to 1342991 Compare July 24, 2025 13:21
@jdm
jdm added this pull request to the merge queue Jul 24, 2025
@jdm
jdm removed this pull request from the merge queue due to a manual request Jul 24, 2025
@jdm

jdm commented Jul 24, 2025 •

Copy link
Copy Markdown
Member

We're just missing the test result changes so this can merge.

Signed-off-by: Jo Steven Novaryo <[email protected]>
@stevennovaryo

Copy link
Copy Markdown
Member Author

We're just missing the test result changes so this can merge.

Sorry, I was in hurry yesterday. Updated the WPT changes, thanks!

@jdm
jdm enabled auto-merge July 25, 2025 02:43
@jdm
jdm added this pull request to the merge queue Jul 25, 2025
Merged via the queue into servo:main with commit 1d89669 Jul 25, 2025
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.

2 participants