Skip to content

Conversation

@sakupi01
Copy link
Contributor

@sakupi01 sakupi01 commented Apr 4, 2025

This PR implements the HTML spec quirk for stylesheets: https://html.spec.whatwg.org/multipage/#link-type-stylesheet

The implementation adds a check in stylesheet_loader.rs to handle this quirk condition correctly, and adds a new WPT test to verify that same-origin non-CSS MIME type resources are properly treated as CSS in quirks mode.

Testing: Added a new WPT test (quirk-origin-check-positive.html) that verifies the positive case for this quirk.
Fixes: #36324

@servo-wpt-sync
Copy link
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#51860) with upstreamable changes.

Signed-off-by: saku-1101 <sakupi1101@outlook.jp>
@sakupi01 sakupi01 force-pushed the fix-stylesheet-quirk-mode branch from 04f2c08 to 5d4ba6b Compare April 4, 2025 15:41
@servo-wpt-sync
Copy link
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#51860) title and body.

@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#51860).

Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

Nice!

Comment on lines 168 to 169
}) || (document.quirks_mode() == QuirksMode::Quirks &&
document.url().origin() == metadata.final_url.origin());
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind linking to the specification and quoting the specification text here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I don't!
Added them here: Add: spec link

@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#51860).

Signed-off-by: saku-1101 <sakupi1101@outlook.jp>
@sakupi01 sakupi01 force-pushed the fix-stylesheet-quirk-mode branch from 30ec85d to 89af76f Compare April 4, 2025 16:32
@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#51860).

// Quirk: If the document has been set to quirks mode, has the same origin as the URL of the external resource, and the Content-Type metadata of the external resource is not a supported style sheet type, the user agent must instead assume it to be text/css.
// <https://html.spec.whatwg.org/multipage/#link-type-stylesheet>
document.quirks_mode() == QuirksMode::Quirks &&
document.url().origin() == metadata.final_url.origin()
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

This matters because web content can set document.origin so it's different than the url's origin.

Signed-off-by: saku-1101 <sakupi1101@outlook.jp>
@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#51860).

@jdm jdm added the T-linux-wpt Do a try run of the WPT label Apr 5, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label Apr 5, 2025
@github-actions
Copy link

github-actions bot commented Apr 5, 2025

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

@github-actions
Copy link

github-actions bot commented Apr 5, 2025

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

Flaky unexpected result (18)
  • FAIL [expected PASS] /_mozilla/css/iframe/hide_and_show.html (#15265)
  • FAIL [expected PASS] /css/css-overflow/line-clamp/line-clamp-with-floats-010.tentative.html (#35018)
  • FAIL [expected PASS] /css/css-sizing/dynamic-available-size-iframe.html (#31559)
  • OK /encoding/legacy-mb-japanese/shift_jis/sjis-encode-form-ms932.html?1-1000 (#36331)
    • FAIL [expected PASS] subtest: U+30AD キ %83%4C

      assert_equals: expected "%83%4C" but got ""
      

    • FAIL [expected PASS] subtest: U+30AE ギ %83%4D

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30AF ク %83%4E

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B0 グ %83%4F

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B1 ケ %83%50

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B2 ゲ %83%51

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B3 コ %83%52

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B4 ゴ %83%53

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B5 サ %83%54

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B6 ザ %83%55

      str is undefined
      

    • And 390 more unexpected results...
  • OK /encoding/legacy-mb-japanese/shift_jis/sjis-encode-form.html?1-1000 (#36261)
    • FAIL [expected PASS] subtest: U+30AD キ %83%4C

      assert_equals: expected "%83%4C" but got ""
      

    • FAIL [expected PASS] subtest: U+30AE ギ %83%4D

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30AF ク %83%4E

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B0 グ %83%4F

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B1 ケ %83%50

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B2 ゲ %83%51

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B3 コ %83%52

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B4 ゴ %83%53

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B5 サ %83%54

      str is undefined
      

    • FAIL [expected PASS] subtest: U+30B6 ザ %83%55

      str is undefined
      

    • And 390 more unexpected results...
  • OK [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/max-payload.tentative.https.window.html
  • OK [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/oversized-payload.tentative.https.window.html (#35210)
  • 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/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/history/the-history-interface/traverse_the_history_5.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])
      

  • TIMEOUT [expected ERROR] /html/canvas/element/manual/imagebitmap/createImageBitmap-flipY.html (#32745)
    • TIMEOUT [expected FAIL] subtest: createImageBitmap from an HTMLVideoElement from a data URL imageOrientation: "from-image", and drawImage on the created ImageBitmap

      Test timed out
      

    • NOTRUN [expected FAIL] subtest: createImageBitmap from an HTMLVideoElement from a data URL imageOrientation: "flipY", and drawImage on the created ImageBitmap
    • NOTRUN [expected FAIL] subtest: createImageBitmap from a bitmap HTMLImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
    • NOTRUN [expected FAIL] subtest: createImageBitmap from a bitmap HTMLImageElement imageOrientation: "flipY", and drawImage on the created ImageBitmap
    • NOTRUN [expected FAIL] subtest: createImageBitmap from a vector HTMLImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
    • NOTRUN [expected FAIL] subtest: createImageBitmap from a vector HTMLImageElement imageOrientation: "flipY", and drawImage on the created ImageBitmap
    • NOTRUN [expected TIMEOUT] subtest: createImageBitmap from a bitmap SVGImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
  • OK [expected ERROR] /html/canvas/element/manual/imagebitmap/createImageBitmap-premultiplyAlpha.html (#35881)
  • TIMEOUT [expected ERROR] /html/canvas/element/manual/imagebitmap/createImageBitmap-transfer.html (#34119)
  • OK /html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document-networkState.html
    • FAIL [expected PASS] subtest: NOT invoking resource selection with implicit pause() when networkState is not NETWORK_EMPTY

      assert_equals: networkState in onerror expected 3 but got 1
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/playing-the-media-resource/loop-from-ended.tentative.html (#33778)
    • FAIL [expected TIMEOUT] subtest: play() with loop set to true after playback ended

      this argument is not a finite floating-point value
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
    • 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/urlencoded2.window.html (#28687)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: Basic test (formdata event)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: 0x00 in value (formdata event)
  • 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
Stable unexpected results that are known to be intermittent (17)
  • OK /FileAPI/url/url-with-fetch.any.html (#21517)
    • PASS [expected FAIL] subtest: Revoke blob URL after calling fetch, fetch should succeed
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #44

      assert_true: could not create image (SVG) expected true got false
      

    • PASS [expected FAIL] subtest: WebGL test #52
    • PASS [expected FAIL] subtest: WebGL test #78
    • PASS [expected FAIL] subtest: WebGL test #82
    • PASS [expected FAIL] subtest: WebGL test #84
  • OK /custom-elements/form-associated/ElementInternals-setFormValue.html (#29174)
    • PASS [expected FAIL] subtest: Single value - name is missing
    • PASS [expected FAIL] subtest: Single value - Non-empty name exists
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Cross-site
  • 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
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-aboutblank-navigate-immediately.html (#29048)
    • TIMEOUT [expected PASS] subtest: Navigating to a different document with link click

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Navigating to a different document with form submission
  • CRASH [expected OK] /html/canvas/offscreen/canvas-host/2d.canvas.host.size.large.worker.html (#30164)
  • OK /html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.html (#24131)
    • PASS [expected FAIL] subtest: web API-created TypeError (structuredClone())
    • PASS [expected FAIL] subtest: web API-created TypeError (worker)
    • PASS [expected FAIL] subtest: web API-created TypeError (cross-site iframe)
    • PASS [expected FAIL] subtest: web API-created TypeError (same-origin iframe)
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected NOTRUN] subtest: Area element should support autofocus

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

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if allow-popups-to-escape-sandbox is used

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

  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html (#24057)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if allow-popups-to-escape-sandbox is used

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

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html (#24066)
  • OK [expected TIMEOUT] /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"
      

  • PASS [expected TIMEOUT] /html/semantics/embedded-content/the-img-element/image-loading-lazy-subframe-detached-crash.html (#31572)
  • TIMEOUT [expected OK] /html/semantics/forms/form-submission-0/reparent-form-during-planned-navigation-task.html (#29724)
    • TIMEOUT [expected PASS] subtest: reparent-form-during-planned-navigation-task

      Test timed out
      

  • 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 domContentLoadedEventEnd &gt; Original domContentLoadedEventEnd

      assert_true: Reload domContentLoadedEventEnd &gt; Original domContentLoadedEventEnd 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
      

@github-actions
Copy link

github-actions bot commented Apr 5, 2025

✨ Try run (#14276734272) succeeded.

@jdm
Copy link
Member

jdm commented Apr 5, 2025

One formatting error that you can resolve with ./mach fmt but otherwise this is good to merge!

Signed-off-by: saku-1101 <sakupi1101@outlook.jp>
@sakupi01
Copy link
Contributor Author

sakupi01 commented Apr 5, 2025

@jdm

Thanks for checking & reporting!
Fixed in: Fix: wpt test-tidy error

@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#51860).

@jdm jdm dismissed mrobinson’s stale review April 5, 2025 12:58

Comments addressed.

@jdm jdm enabled auto-merge April 5, 2025 12:58
@sakupi01 sakupi01 requested review from jdm and mrobinson April 6, 2025 00:17
@jdm jdm added this pull request to the merge queue Apr 6, 2025
@sakupi01 sakupi01 requested a review from jdm April 6, 2025 00:28
Merged via the queue into servo:main with commit b4fd9eb Apr 6, 2025
21 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.

Stylesheet loading quirk is missing

5 participants