-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1452928 [wpt PR 8449] - Add more XMLHttpRequest overrideMimeType(…
…) tests, a=testonly Automatic update from web-platform-testsAdd more XMLHttpRequest overrideMimeType() tests For whatwg/xhr#157, whatwg/xhr#174, and whatwg/mimesniff#42. -- wpt-commits: ae41496630ba35cff974877498383f1280ca07c2 wpt-pr: 8449 UltraBlame original commit: a743786f569a9e77f8c86a2882abee702f58f981
- Loading branch information
Showing
5 changed files
with
102 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
testing/web-platform/tests/xhr/overridemimetype-edge-cases.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const testURL = "resources/status.py?type=" + encodeURIComponent("text/plain;charset=windows-1252") + "&content=%C2%F0"; | ||
|
||
async_test(t => { | ||
const client = new XMLHttpRequest(); | ||
let secondTime = false; | ||
client.onload = t.step_func(() => { | ||
if(!secondTime) { | ||
assert_equals(client.responseText, "\uFFFD"); | ||
secondTime = true; | ||
client.open("GET", testURL); | ||
client.send(); | ||
} else { | ||
assert_equals(client.responseText, "Âð"); | ||
t.done(); | ||
} | ||
}); | ||
client.open("GET", testURL); | ||
client.overrideMimeType("text/plain;charset=UTF-8") | ||
client.send(); | ||
}, "overrideMimeType() state needs to be reset across requests"); | ||
|
||
async_test(t => { | ||
const client = new XMLHttpRequest(); | ||
client.onload = t.step_func_done(() => { | ||
assert_equals(client.responseText, "Âð") | ||
}); | ||
client.open("GET", testURL); | ||
client.overrideMimeType("text/xml"); | ||
client.send(); | ||
}, "If charset is not overridden by overrideMimeType() the original continues to be used"); | ||
|
||
async_test(t => { | ||
const client = new XMLHttpRequest(); | ||
client.onload = t.step_func_done(() => { | ||
assert_equals(client.responseText, "\uFFFD") | ||
}); | ||
client.open("GET", testURL); | ||
client.overrideMimeType("text/plain;charset=342"); | ||
client.send(); | ||
}, "Charset can be overridden by overrideMimeType() with a bogus charset"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters