Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update overrideMimeType and final-charset to match xhr spec #29812

Merged
merged 3 commits into from Feb 28, 2024

Conversation

CYBAI
Copy link
Member

@CYBAI CYBAI commented May 29, 2023

While looking into issues related to overridemimetype, I noticed it doesn't match the spec because the method is updated several times in the past few years.

But, there are still remaining failures for tests in xhr/overridemimetype-blob.html so this PR aims to match the spec first and investigate remaining failures in a separate PR.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes

@CYBAI
Copy link
Member Author

CYBAI commented May 29, 2023

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

⌛ Trying commit 42ac6a8 with merge 7547a61...

bors-servo added a commit that referenced this pull request May 29, 2023
Update overrideMimeType and final-encoding to match xhr spec

While looking into issues related to `overridemimetype`, I noticed it doesn't match the spec because the method is updated several times in the past few years.

But, there are still remaining failures for tests in `xhr/overridemimetype-blob.html` so this PR aims to match the spec first and investigate remaining failures in a separate PR.

---

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
- [x] There are tests for these changes
@CYBAI CYBAI changed the title Update overrideMimeType and final-encoding to match xhr spec Update overrideMimeType and final-charset to match xhr spec May 29, 2023
@github-actions
Copy link

Test results for linux-wpt-layout-2013 from try job (#5112992342):

Flaky unexpected result (17)
  • TIMEOUT [expected OK] /FileAPI/url/url-charset.window.html (#26997)
    • TIMEOUT [expected PASS] subtest: Blob charset should override any auto-detected charset. Test timed out
  • OK /_mozilla/css/stylesheet_media_queries.html (#17159)
    • FAIL [expected PASS] subtest: Media queries within stylesheets assert_equals: expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-uniform-packing-restrictions.html (#28103)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-with-non-reserved-words.html (#16216)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected ERROR] /html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html (#28541)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html (#28691)
    • PASS [expected FAIL] subtest: load event does not fire on window.open('about:blank')
  • 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"
  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html (#24161)
    • TIMEOUT [expected PASS] subtest: Autofocus elements queued in another top-level browsing context's documents should be skipped. Test timed out
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html (#24057)
    • TIMEOUT [expected FAIL] subtest: Check that popups from a sandboxed iframe escape the sandbox if
      allow-popups-to-escape-sandbox is used Test timed out
  • OK /html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html (#23205)
    • PASS [expected FAIL] subtest: Check that rel=noopener with target=_self does a normal load
  • OK /html/webappapis/dynamic-markup-insertion/document-write/module-delayed.html (#27659)
    • FAIL [expected PASS] subtest: async document.write in a module assert_true: onload must be called expected true got false
  • TIMEOUT /html/webappapis/scripting/events/compile-event-handler-settings-objects.html (#24246)
    • TIMEOUT [expected FAIL] subtest: The entry settings object while executing the compiled callback via Web IDL's invoke must be that of the node document Test timed out
  • TIMEOUT [expected OK] /html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.html (#26371)
    • TIMEOUT [expected FAIL] subtest: delayed handling: delaying handling rejected promise created from createImageBitmap will cause both events to fire Test timed out
  • CRASH [expected TIMEOUT] /webmessaging/broadcastchannel/cross-partition.https.tentative.html (#29058)
  • 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:
Stable unexpected results that are known to be intermittent (19)
  • OK [expected TIMEOUT] /fetch/api/basic/keepalive.any.html (#29536)
  • OK /fetch/local-network-access/worker-blob-fetch.window.html (#29602)
    • FAIL [expected PASS] subtest: local https to local https: success. assert_equals: fetch error expected (undefined) undefined but got (string) "unknown error"
  • TIMEOUT /fetch/metadata/generated/css-images.sub.tentative.html (#29047)
    • FAIL [expected PASS] subtest: border-image sec-fetch-user - Not sent to non-trustworthy cross-site destination assert_unreached: Reached unreachable code
    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-site - HTTPS downgrade (header not sent) Test timed out
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (#28681)
    • FAIL [expected PASS] subtest: load & pageshow events do not fire on contentWindow of <iframe> element created with src='' 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"
  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
  • OK [expected TIMEOUT] /html/browsers/history/the-history-interface/traverse-during-unload.html (#28688)
    • PASS [expected TIMEOUT] subtest: Traversing the history during unload
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/autofocus-dialog.html (#29087)
    • FAIL [expected TIMEOUT] subtest: <dialog>-contained autofocus element gets focused when the dialog is shown promise_test: Unhandled rejection with value: object "TypeError: w.document.querySelector(...).show is not a function"
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected TIMEOUT] subtest: Element with tabindex should support autofocus assert_equals: expected "SPAN" but got "BODY"
    • PASS [expected NOTRUN] subtest: Non-HTMLElement should not support autofocus
    • FAIL [expected NOTRUN] subtest: Host element with delegatesFocus should support autofocus promise_test: Unhandled rejection with value: object "TypeError: host.attachShadow is not a function"
    • FAIL [expected NOTRUN] subtest: Host element with delegatesFocus including no focusable descendants should be skipped promise_test: Unhandled rejection with value: object "TypeError: host.attachShadow is not a function"
    • 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/interaction/focus/the-autofocus-attribute/update-the-rendering.html (#24145)
    • FAIL [expected TIMEOUT] subtest: "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks w.focus is not a function
  • OK /html/semantics/embedded-content/media-elements/media_fragment_seek.html (#24114)
    • PASS [expected FAIL] subtest: Video should seek to time specified in media fragment syntax
  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.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"
  • TIMEOUT [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
    • NOTRUN [expected FAIL] subtest: Check that popups from a sandboxed iframe do not escape the sandbox
  • OK /html/semantics/forms/form-submission-0/multipart-formdata.window.html (#28725)
    • FAIL [expected PASS] subtest: multipart/form-data: 0x00 in name (normal form) assert_equals: expected "\r\nContent-Disposition: form-data; name="a\0b"\r\n\r\nc\r\n--\r\n" but got ""
  • OK /html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html (#26243)
    • PASS [expected FAIL] subtest: document.write in an imported module
  • OK [expected TIMEOUT] /html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue/promise-job-entry.html (#25805)
  • OK [expected TIMEOUT] /webmessaging/with-ports/018.html (#24485)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, javascript:
  • ERROR [expected OK] /workers/constructors/Worker/Worker-constructor.html (#22991)
  • OK /workers/dedicated-worker-from-blob-url.window.html (#22286)
    • FAIL [expected PASS] subtest: Creating a dedicated worker from a blob URL works immediately before revoking. promise_test: Unhandled rejection with value: object "[object Event]"
Stable unexpected results (9)
  • OK /encoding/single-byte-decoder.window.html?XMLHttpRequest
    • PASS [expected FAIL] subtest: ISO-8859-2: iso_8859-2:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-3: iso_8859-3:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-4: iso_8859-4:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-5: iso_8859-5:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-6: iso_8859-6:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-7: iso_8859-7:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-8: iso_8859-8:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: windows-1252: iso_8859-1:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: windows-1254: iso_8859-9:1989 (XMLHttpRequest)
  • OK /xhr/overridemimetype-blob.html
    • PASS [expected FAIL] subtest: 1) MIME types need to be parsed and serialized: text/html;charset=gbk
    • PASS [expected FAIL] subtest: 16) MIME types need to be parsed and serialized: text/html;charset='gbk'
    • PASS [expected FAIL] subtest: 17) MIME types need to be parsed and serialized: text/html;charset='gbk
    • PASS [expected FAIL] subtest: 18) MIME types need to be parsed and serialized: text/html;charset=gbk'
    • PASS [expected FAIL] subtest: 31) MIME types need to be parsed and serialized: text/html;charset=" gbk"
    • PASS [expected FAIL] subtest: 32) MIME types need to be parsed and serialized: text/html;charset="gbk "
    • PASS [expected FAIL] subtest: 39) MIME types need to be parsed and serialized: text/html;0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk
    • PASS [expected FAIL] subtest: 42) MIME types need to be parsed and serialized: text/html;valid=";";foo=bar
    • PASS [expected FAIL] subtest: 55) MIME types need to be parsed and serialized: �x/x
    • PASS [expected FAIL] subtest: 56) MIME types need to be parsed and serialized: x/x
    • And 17 more unexpected results...
  • OK /xhr/overridemimetype-edge-cases.window.html
    • FAIL [expected PASS] subtest: overrideMimeType() is not reset by open(), basic assert_equals: expected "\ufffd\ufffd" but got "Âð"
    • FAIL [expected PASS] subtest: overrideMimeType() is not reset by open() assert_equals: expected "\ufffd\ufffd" but got "Âð"
  • OK /xhr/overridemimetype-headers-received-state-force-shiftjis.htm
    • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in HEADERS RECEIVED state, enforcing Shift-JIS encoding assert_equals: overrideMimeType() in HEADERS RECEIVED state set encoding expected "テスト" but got "\ufffde\ufffdX\ufffdg"
  • OK /xhr/overridemimetype-invalid-mime-type.htm
    • PASS [expected FAIL] subtest: Bogus MIME type does not override encoding
    • PASS [expected FAIL] subtest: Bogus MIME type does not override encoding, 2
    • PASS [expected FAIL] subtest: Bogus MIME type does override MIME type
  • ERROR [expected OK] /xhr/overridemimetype-open-state-force-utf-8.htm
    • TIMEOUT [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in open state, enforcing UTF-8 encoding Test timed out
  • ERROR [expected OK] /xhr/overridemimetype-open-state-force-xml.htm
    • TIMEOUT [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in open state, XML MIME type with UTF-8 charset Test timed out
  • OK /xhr/overridemimetype-unsent-state-force-shiftjis.any.html
    • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in unsent state, enforcing Shift-JIS encoding assert_equals: expected "テスト" but got "ƒeƒXƒg"
  • OK /xhr/overridemimetype-unsent-state-force-shiftjis.any.worker.html
    • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in unsent state, enforcing Shift-JIS encoding assert_equals: expected "テスト" but got "ƒeƒXƒg"

@bors-servo
Copy link
Contributor

💔 Test failed - checks-github

@CYBAI
Copy link
Member Author

CYBAI commented May 29, 2023

I will look into the unexpected TIMEOUTs and failures 👀

@CYBAI CYBAI marked this pull request as draft May 31, 2023 03:15
@mrobinson
Copy link
Member

@bors-servo try=wpt

@github-actions
Copy link

🔨 Triggering try run (#6198188414) with platform=linux and layout=2013

@mrobinson
Copy link
Member

Kicking off a new try job in the case that the timeouts are actually panics.

@servo-wpt-sync
Copy link
Collaborator

🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync.

@github-actions
Copy link

Test results for linux-wpt-layout-2013 from try job (#6198188414):

Flaky unexpected result (19)
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-uniform-packing-restrictions.html (#28103)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-with-non-reserved-words.html (#16216)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected PASS] /css/CSS2/margin-padding-clear/padding-top-025.xht
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
  • 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 form submission
  • OK /html/browsers/browsing-the-web/overlapping-navigations-and-traversals/cross-document-nav-same-document-traversal.html
    • PASS [expected FAIL] subtest: cross-document navigations are stopped by same-document back()
  • TIMEOUT [expected OK] /html/browsers/history/the-history-interface/traverse-during-unload.html (#28688)
    • TIMEOUT [expected PASS] subtest: Traversing the history during unload Test timed out
  • OK /html/browsers/history/the-history-interface/traverse_the_history_2.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • OK /html/browsers/the-window-object/open-close/creating_browsing_context_test_01.html (#29046)
  • PASS [expected CRASH] /html/canvas/element/manual/drawing-text-to-the-canvas/canvas.2d.disconnected-font-size-math.html (#30063)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
    • 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 /html/semantics/embedded-content/the-img-element/non-active-document.html (#21544)
    • PASS [expected FAIL] subtest: createHTMLDocument
    • PASS [expected FAIL] subtest: <template>
  • OK /html/semantics/forms/form-submission-0/multipart-formdata.window.html (#28725)
    • PASS [expected FAIL] subtest: multipart/form-data: 0x00 in value (normal form)
  • OK /html/semantics/forms/form-submission-0/text-plain.window.html (#28687)
    • PASS [expected FAIL] subtest: text/plain: backslash in value (normal form)
  • ERROR [expected OK] /html/semantics/scripting-1/the-script-element/defer-script/async-script.html?reload (#29054)
  • OK /html/syntax/parsing/DOMContentLoaded-defer.html (#21550)
    • PASS [expected FAIL] subtest: The end: DOMContentLoaded and defer scripts
  • OK /resource-timing/status-codes-create-entry.html (#28675)
    • PASS [expected FAIL] subtest: Make sure all status codes are reported
  • OK [expected TIMEOUT] /webmessaging/with-ports/018.html (#24485)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, javascript:
Stable unexpected results that are known to be intermittent (16)
  • OK /_mozilla/css/stylesheet_media_queries.html (#17159)
    • FAIL [expected PASS] subtest: Media queries within stylesheets assert_equals: expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
  • OK /css/css-fonts/variations/font-weight-matching.html (#20686)
    • FAIL [expected PASS] subtest: Test @font-face matching for weight 100 assert_approx_equals: @font-face should be mapped to CSSTest Weights 900. expected 90 +/- 2 but got 180
  • OK /css/cssom-view/elementFromPoint-list-001.html (#23915)
    • PASS [expected FAIL] subtest: <li>Outside 1</li>
    • PASS [expected FAIL] subtest: <li>Outside 3</li>
    • PASS [expected FAIL] subtest: <li>Image Outside 2</li>
  • TIMEOUT [expected OK] /fetch/api/redirect/redirect-keepalive.any.html (#29536)
  • TIMEOUT /fetch/metadata/generated/css-images.sub.tentative.html (#29047)
    • PASS [expected TIMEOUT] subtest: background-image sec-fetch-dest - Not sent to non-trustworthy same-site destination
    • PASS [expected TIMEOUT] subtest: background-image sec-fetch-site - HTTPS downgrade (header not sent)
    • PASS [expected FAIL] subtest: border-image sec-fetch-site - HTTPS downgrade (header not sent)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling-dynamic.html (#28066)
    • FAIL [expected PASS] subtest: 0080 00FF 0100 set in href="" targeting a frame and clicked assert_equals: expected "�ÿĀ" but got ""
  • 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])
  • OK /html/browsers/history/the-location-interface/location-protocol-setter.html (#20839)
    • PASS [expected FAIL] subtest: Equivalent tests for data URL and srcdoc <iframe>s
  • OK [expected CRASH] /html/canvas/offscreen/the-offscreen-canvas/size.attributes.parse.minus.worker.html (#30164)
  • 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 /html/semantics/forms/form-submission-0/urlencoded2.window.html (#28687)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: 0x00 in name (formdata event)
  • OK /html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html (#26243)
    • PASS [expected FAIL] subtest: document.write in an imported module
  • TIMEOUT /html/webappapis/scripting/events/compile-event-handler-settings-objects.html (#24246)
    • FAIL [expected PASS] subtest: The entry settings object while executing the compiled callback via Web IDL's invoke must be that of the node document assert_equals: expected "/html/webappapis/scripting/events/resources/open-window.html" but got "blank"
  • PASS [expected CRASH] /streams/readable-streams/crashtests/strategy-worker-terminate.html (#30124)
  • TIMEOUT [expected OK] /webmessaging/with-ports/017.html (#24486)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, about:blank Test timed out
  • ERROR [expected OK] /workers/constructors/Worker/Worker-constructor.html (#22991)
Stable unexpected results (9)
  • OK /encoding/single-byte-decoder.window.html?XMLHttpRequest
    • PASS [expected FAIL] subtest: ISO-8859-2: iso_8859-2:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-3: iso_8859-3:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-4: iso_8859-4:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-5: iso_8859-5:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-6: iso_8859-6:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-7: iso_8859-7:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-8: iso_8859-8:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: windows-1252: iso_8859-1:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: windows-1254: iso_8859-9:1989 (XMLHttpRequest)
  • OK /xhr/overridemimetype-blob.html
    • PASS [expected FAIL] subtest: 1) MIME types need to be parsed and serialized: text/html;charset=gbk
    • PASS [expected FAIL] subtest: 16) MIME types need to be parsed and serialized: text/html;charset='gbk'
    • PASS [expected FAIL] subtest: 17) MIME types need to be parsed and serialized: text/html;charset='gbk
    • PASS [expected FAIL] subtest: 18) MIME types need to be parsed and serialized: text/html;charset=gbk'
    • PASS [expected FAIL] subtest: 31) MIME types need to be parsed and serialized: text/html;charset=" gbk"
    • PASS [expected FAIL] subtest: 32) MIME types need to be parsed and serialized: text/html;charset="gbk "
    • PASS [expected FAIL] subtest: 39) MIME types need to be parsed and serialized: text/html;0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk
    • PASS [expected FAIL] subtest: 42) MIME types need to be parsed and serialized: text/html;valid=";";foo=bar
    • PASS [expected FAIL] subtest: 55) MIME types need to be parsed and serialized: �x/x
    • PASS [expected FAIL] subtest: 56) MIME types need to be parsed and serialized: x/x
    • And 17 more unexpected results...
  • OK /xhr/overridemimetype-edge-cases.window.html
    • FAIL [expected PASS] subtest: overrideMimeType() is not reset by open(), basic assert_equals: expected "\ufffd\ufffd" but got "Âð"
    • FAIL [expected PASS] subtest: overrideMimeType() is not reset by open() assert_equals: expected "\ufffd\ufffd" but got "Âð"
  • OK /xhr/overridemimetype-headers-received-state-force-shiftjis.htm
    • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in HEADERS RECEIVED state, enforcing Shift-JIS encoding assert_equals: overrideMimeType() in HEADERS RECEIVED state set encoding expected "テスト" but got "\ufffde\ufffdX\ufffdg"
  • OK /xhr/overridemimetype-invalid-mime-type.htm
    • PASS [expected FAIL] subtest: Bogus MIME type does not override encoding
    • PASS [expected FAIL] subtest: Bogus MIME type does not override encoding, 2
    • PASS [expected FAIL] subtest: Bogus MIME type does override MIME type
  • ERROR [expected OK] /xhr/overridemimetype-open-state-force-utf-8.htm
    • TIMEOUT [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in open state, enforcing UTF-8 encoding Test timed out
  • ERROR [expected OK] /xhr/overridemimetype-open-state-force-xml.htm
    • TIMEOUT [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in open state, XML MIME type with UTF-8 charset Test timed out
  • OK /xhr/overridemimetype-unsent-state-force-shiftjis.any.html
    • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in unsent state, enforcing Shift-JIS encoding assert_equals: expected "テスト" but got "ƒeƒXƒg"
  • OK /xhr/overridemimetype-unsent-state-force-shiftjis.any.worker.html
    • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in unsent state, enforcing Shift-JIS encoding assert_equals: expected "テスト" but got "ƒeƒXƒg"

@github-actions
Copy link

⚠️ Try run (#6198188414) failed.

@mrobinson
Copy link
Member

Here is the information about the timeouts and errors:

   • ERROR [expected OK] /xhr/overridemimetype-open-state-force-utf-8.htm
      uncaught exception: Error: assert_equals: expected "テスト" but got "繝\ufffdせ繝\ufffd"
      client.onreadystatechange@http://web-platform.test:8000/xhr/overridemimetype-open-state-force-utf-8.htm:18:24
      • TIMEOUT [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in open state, enforcing UTF-8 encoding Test timed out
        Test timed out

    • ERROR [expected OK] /xhr/overridemimetype-open-state-force-xml.htm
      uncaught exception: Error: assert_equals: expected "Hello World!" but got "Hello World\ufffd\ufffd"
      client.onreadystatechange@http://web-platform.test:8000/xhr/overridemimetype-open-state-force-xml.htm:25:24
      • TIMEOUT [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in open state, XML MIME type with UTF-8 charset Test timed out
        Test timed out

    • OK /xhr/overridemimetype-unsent-state-force-shiftjis.any.html
      • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in unsent state, enforcing Shift-JIS encoding assert_equals: expected "テスト" but got "ƒeƒXƒg"
        assert_equals: expected "テスト" but got "ƒeƒXƒg"

    • OK /xhr/overridemimetype-unsent-state-force-shiftjis.any.worker.html
      • FAIL [expected PASS] subtest: XMLHttpRequest: overrideMimeType() in unsent state, enforcing Shift-JIS encoding assert_equals: expected "テスト" but got "ƒeƒXƒg"

It looks like there is a bit of work to do on the implementation of this feature.

@mrobinson mrobinson added the T-linux-wpt-2020 Do a try run of the WPT label Feb 28, 2024
@github-actions github-actions bot removed the T-linux-wpt-2020 Do a try run of the WPT label Feb 28, 2024
Copy link

🔨 Triggering try run (#8085114293) for Linux WPT

Copy link

Test results for linux-wpt-layout-2020 from try job (#8085114293):

Flaky unexpected result (21)
  • TIMEOUT [expected PASS] /_mozilla/css/transition_calc_implicit.html (#17417)
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-with-non-reserved-words.html (#16216)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • PASS [expected FAIL] subtest: Matching font-weight: '501' should prefer '501' over '502 510'
    • PASS [expected FAIL] subtest: Matching font-weight: '501' should prefer '500' over '450 460'
    • PASS [expected FAIL] subtest: Matching font-weight: '501' should prefer '450 460' over '390 410'
    • PASS [expected FAIL] subtest: Matching font-stretch: '100%' should prefer '100%' over '110% 120%'
    • PASS [expected FAIL] subtest: Matching font-stretch: '110%' should prefer '105%' over '100%'
    • PASS [expected FAIL] subtest: Matching font-style: 'normal' should prefer 'normal' over 'oblique 0deg'
    • PASS [expected FAIL] subtest: Matching font-style: 'italic' should prefer 'oblique 40deg 50deg' over 'oblique 5deg 10deg'
    • PASS [expected FAIL] subtest: Matching font-style: 'italic' should prefer 'normal' over 'oblique 0deg'
    • PASS [expected FAIL] subtest: Matching font-style: 'oblique 21deg' should prefer 'oblique 40deg 50deg' over 'oblique 20deg'
    • PASS [expected FAIL] subtest: Matching font-style: 'oblique 21deg' should prefer 'oblique 10deg' over 'italic'
    • And 2 more unexpected results...
  • TIMEOUT [expected FAIL] /css/css-images/object-view-box-property-changed.html
  • OK /css/cssom-view/MediaQueryList-addListener-handleEvent.html (#24571)
    • FAIL [expected PASS] subtest: calls handleEvent method of event listener assert_equals: expected (object) object "[object Object]" but got (undefined) undefined
  • OK /html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling-dynamic.html (#28066)
    • FAIL [expected PASS] subtest: 0041 set in href="" targeting a frame and clicked assert_equals: expected "A" but got ""
    • FAIL [expected PASS] subtest: 0080 00FF set in href="" targeting a frame and clicked assert_equals: expected "�ÿ" but got ""
    • FAIL [expected PASS] subtest: 0080 00FF 0100 set in href="" targeting a frame and clicked assert_equals: expected "�ÿĀ" but got ""
    • FAIL [expected PASS] subtest: D83D DE0D set in href="" targeting a frame and clicked assert_equals: expected "😍" but got ""
    • FAIL [expected PASS] subtest: DE0D 0041 set in href="" targeting a frame and clicked assert_equals: expected "\ufffdA" but got ""
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/navigate-to-unparseable-url.html (#29050)
    • TIMEOUT [expected FAIL] subtest: <a> tag navigate fails for unparseable URLs Test timed out
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • PASS [expected FAIL] subtest: Same-origin navigation started from unload handler must be ignored
  • CRASH [expected OK] /html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html
  • OK /html/browsers/history/the-history-interface/traverse_the_history_3.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
    • 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_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"
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • OK /html/semantics/embedded-content/the-img-element/non-active-document.html (#21544)
    • FAIL [expected PASS] subtest: DOMParser assert_unreached: got unexpected load event Reached unreachable code
    • FAIL [expected PASS] subtest: createHTMLDocument assert_unreached: got unexpected error event Reached unreachable code
    • FAIL [expected PASS] subtest: <template> assert_unreached: got unexpected error event Reached unreachable code
  • OK /html/semantics/forms/form-submission-0/text-plain.window.html (#28687)
    • PASS [expected FAIL] subtest: text/plain: 0x00 in name (formdata event)
  • OK /html/semantics/forms/form-submission-0/urlencoded2.window.html (#28687)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: double quote in name (formdata event)
  • TIMEOUT /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 TIMEOUT] subtest: Test that iframe refreshes are not observable by the parent
  • 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)
    • FAIL [expected PASS] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (img) assert_equals: expected 16372736 but got 16372992
  • TIMEOUT [expected OK] /webmessaging/without-ports/018.html (#24485)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, javascript: Test timed out
Stable unexpected results that are known to be intermittent (11)
Stable unexpected results (4)
  • OK /encoding/single-byte-decoder.window.html?XMLHttpRequest
    • PASS [expected FAIL] subtest: ISO-8859-2: iso_8859-2:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-3: iso_8859-3:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-4: iso_8859-4:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-5: iso_8859-5:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-6: iso_8859-6:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-7: iso_8859-7:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: ISO-8859-8: iso_8859-8:1988 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: windows-1252: iso_8859-1:1987 (XMLHttpRequest)
    • PASS [expected FAIL] subtest: windows-1254: iso_8859-9:1989 (XMLHttpRequest)
  • OK /xhr/overridemimetype-blob.html
    • PASS [expected FAIL] subtest: 1) MIME types need to be parsed and serialized: text/html;charset=gbk
    • PASS [expected FAIL] subtest: 16) MIME types need to be parsed and serialized: text/html;charset='gbk'
    • PASS [expected FAIL] subtest: 17) MIME types need to be parsed and serialized: text/html;charset='gbk
    • PASS [expected FAIL] subtest: 18) MIME types need to be parsed and serialized: text/html;charset=gbk'
    • PASS [expected FAIL] subtest: 31) MIME types need to be parsed and serialized: text/html;charset=" gbk"
    • PASS [expected FAIL] subtest: 32) MIME types need to be parsed and serialized: text/html;charset="gbk "
    • PASS [expected FAIL] subtest: 39) MIME types need to be parsed and serialized: text/html;0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk
    • PASS [expected FAIL] subtest: 42) MIME types need to be parsed and serialized: text/html;valid=";";foo=bar
    • PASS [expected FAIL] subtest: 55) MIME types need to be parsed and serialized: �x/x
    • PASS [expected FAIL] subtest: 56) MIME types need to be parsed and serialized: x/x
    • And 17 more unexpected results...
  • OK /xhr/overridemimetype-edge-cases.window.html
    • PASS [expected FAIL] subtest: Charset can be overridden by overrideMimeType() with a bogus charset
  • OK /xhr/overridemimetype-invalid-mime-type.htm
    • PASS [expected FAIL] subtest: Bogus MIME type does not override encoding
    • PASS [expected FAIL] subtest: Bogus MIME type does not override encoding, 2
    • PASS [expected FAIL] subtest: Bogus MIME type does override MIME type

Copy link

⚠️ Try run (#8085114293) failed.

@mrobinson
Copy link
Member

I think this is ready to go with a small fix:

commit 8456b742333aa396692690a69c9feafc39b11fd5
Author: Martin Robinson <mrobinson@igalia.com>
Date:   Wed Feb 28 19:10:16 2024 +0100

    Fix an issue and add more comments

diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 1f5977299e..e748d23d6b 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -889,9 +889,10 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
         ByteString::new(v)
     }
 
-    // https://xhr.spec.whatwg.org/#the-overridemimetype()-method
+    /// <https://xhr.spec.whatwg.org/#the-overridemimetype()-method>
     fn OverrideMimeType(&self, mime: DOMString) -> ErrorResult {
-        // Step 1
+        // 1. If this’s state is loading or done, then throw an "InvalidStateError"
+        //   DOMException.
         match self.ready_state.get() {
             XMLHttpRequestState::Loading | XMLHttpRequestState::Done => {
                 return Err(Error::InvalidState);
@@ -899,7 +900,9 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
             _ => {},
         }
 
-        // Step 2-3.
+        // 2. Set this’s override MIME type to the result of parsing mime.
+        // 3. If this’s override MIME type is failure, then set this’s override MIME type
+        //    to application/octet-stream.
         let override_mime = match mime.parse::<Mime>() {
             Ok(mime) => mime,
             Err(_) => "application/octet-stream"
@@ -908,7 +911,6 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
         };
 
         *self.override_mime_type.borrow_mut() = Some(override_mime);
-
         Ok(())
     }
 
@@ -1598,20 +1600,26 @@ impl XMLHttpRequest {
 
     /// <https://xhr.spec.whatwg.org/#final-charset>
     fn final_charset(&self) -> Option<&'static Encoding> {
-        // Step 2-3.
+        // 1. Let label be null.
+        // 2. Let responseMIME be the result of get a response MIME type for xhr.
+        // 3. If responseMIME’s parameters["charset"] exists, then set label to it.
         let response_charset = self
             .response_mime_type()
             .and_then(|mime| mime.get_param(mime::CHARSET).map(|c| c.to_string()));
 
-        // Step 4.
+        // 4. If xhr’s override MIME type’s parameters["charset"] exists, then set label to it.
         let override_charset = self
             .override_mime_type
             .borrow()
             .as_ref()
             .and_then(|mime| mime.get_param(mime::CHARSET).map(|c| c.to_string()));
 
-        response_charset
-            .or(override_charset)
+        // 5. If label is null, then return null.
+        // 6. Let encoding be the result of getting an encoding from label.
+        // 7. If encoding is failure, then return null.
+        // 8. Return encoding.
+        override_charset
+            .or(response_charset)
             .and_then(|charset| Encoding::for_label(&charset.as_bytes()))
     }
 

@mrobinson mrobinson marked this pull request as ready for review February 28, 2024 19:52
@mrobinson mrobinson added this pull request to the merge queue Feb 28, 2024
Merged via the queue into servo:main with commit a89bacb Feb 28, 2024
9 checks passed
@CYBAI CYBAI deleted the xhr-overridemimetype branch March 6, 2024 04:38
@CYBAI
Copy link
Member Author

CYBAI commented Mar 6, 2024

Martin, thanks for fixing this 🙏

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.

None yet

4 participants