mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Update web-platform-tests to revision 346d5b51a122f7bb1c7747064499ef281a0200f7
This commit is contained in:
parent
581c8ba1c8
commit
79b1e6c40c
1728 changed files with 20243 additions and 5349 deletions
|
@ -0,0 +1,124 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onprogress" data-tested-assertations="../.." />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#event-xhr-progress" data-tested-assertations="../.." />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::dt[@id="dom-xmlhttprequest-send-bodyinit"]/following::dd[1]/p[2] following::ol[1]/li[9]//li[1] following::ol[1]/li[9]//li[2]" />
|
||||
<link rel="help" href="https://fetch.spec.whatwg.org/#http-fetch" data-tested-assertations="following::ol[1]/li[6]/dl/dd[1]//dd[3]" />
|
||||
<link rel="help" href="https://fetch.spec.whatwg.org/#concept-http-redirect-fetch" data-tested-assertations="following::li[16]" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<title>XMLHttpRequest: The send() method: POSTing to URL that redirects</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function testRedirectPost(code, shouldResendPost) {
|
||||
var test = async_test(document.title + " (" + code + ")");
|
||||
var actual = [];
|
||||
// We check upload.onprogress with a boolean because it *might* fire more than once
|
||||
var progressFiredReadyState1 = false;
|
||||
|
||||
var expectedHeaders, expectedEvents;
|
||||
|
||||
// 307 redirects should resend the POST data, and events and headers will be a little different..
|
||||
if(shouldResendPost) {
|
||||
expectedHeaders = {
|
||||
"X-Request-Content-Length": "11988",
|
||||
"X-Request-Content-Type": "text/plain;charset=UTF-8",
|
||||
"X-Request-Method": "POST",
|
||||
"X-Request-Query": "NO",
|
||||
"Content-Length": "11988"
|
||||
}
|
||||
expectedEvents = [
|
||||
"xhr onreadystatechange 1",
|
||||
"xhr loadstart 1",
|
||||
"upload loadstart 1",
|
||||
"upload loadend 1",
|
||||
"xhr onreadystatechange 2",
|
||||
"xhr onreadystatechange 3",
|
||||
"xhr onreadystatechange 4",
|
||||
"xhr load 4",
|
||||
"xhr loadend 4"
|
||||
];
|
||||
} else {
|
||||
// setting the right expectations for POST resent as GET without request body
|
||||
expectedHeaders = {
|
||||
"X-Request-Content-Length": "NO",
|
||||
"X-Request-Content-Type": "NO",
|
||||
"X-Request-Method": "GET",
|
||||
"X-Request-Query": "NO"
|
||||
}
|
||||
expectedEvents = [
|
||||
"xhr onreadystatechange 1",
|
||||
"xhr loadstart 1",
|
||||
"upload loadstart 1",
|
||||
"upload loadend 1",
|
||||
"xhr onreadystatechange 2",
|
||||
/* we expect no onreadystatechange readyState=3 event because there is no loading content */
|
||||
"xhr onreadystatechange 4",
|
||||
"xhr load 4",
|
||||
"xhr loadend 4"
|
||||
];
|
||||
}
|
||||
test.step(function()
|
||||
{
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.upload.onloadstart = test.step_func(function(e) {
|
||||
actual.push("upload loadstart " + xhr.readyState);
|
||||
});
|
||||
xhr.upload.onprogress = test.step_func(function(e) {
|
||||
// events every 50ms, one final when uploading is done
|
||||
if(xhr.readyState >= xhr.HEADERS_RECEIVED) {
|
||||
assert_equals(xhr.status, 200, "JS never gets to see the 30x status code");
|
||||
}
|
||||
progressFiredReadyState1 = xhr.readyState === xhr.OPENED;
|
||||
});
|
||||
xhr.upload.onloadend = test.step_func(function() {
|
||||
actual.push("upload loadend " + xhr.readyState);
|
||||
});
|
||||
xhr.onloadstart = test.step_func(function() {
|
||||
actual.push("xhr loadstart " + xhr.readyState);
|
||||
});
|
||||
xhr.onreadystatechange = test.step_func(function() {
|
||||
if(xhr.readyState >= xhr.HEADERS_RECEIVED) {
|
||||
assert_equals(xhr.status, 200, "JS never gets to see the 30x status code");
|
||||
}
|
||||
actual.push("xhr onreadystatechange " + xhr.readyState);
|
||||
});
|
||||
xhr.onload = test.step_func(function(e)
|
||||
{
|
||||
actual.push("xhr load " + xhr.readyState);
|
||||
});
|
||||
xhr.onloadend = test.step_func(function(e)
|
||||
{
|
||||
actual.push("xhr loadend " + xhr.readyState);
|
||||
|
||||
assert_true(progressFiredReadyState1, "One progress event should fire on xhr.upload when readyState is 1");
|
||||
|
||||
// Headers will tell us if data was sent when expected
|
||||
for(var header in expectedHeaders) {
|
||||
assert_equals(xhr.getResponseHeader(header), expectedHeaders[header], header);
|
||||
}
|
||||
|
||||
assert_array_equals(actual, expectedEvents, "events firing in expected order and states");
|
||||
test.done();
|
||||
});
|
||||
|
||||
xhr.open("POST", "./resources/redirect.py?location=content.py&code=" + code, true);
|
||||
xhr.send((new Array(1000)).join("Test Message"));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
testRedirectPost(301, false);
|
||||
testRedirectPost(302, false);
|
||||
testRedirectPost(303, false);
|
||||
testRedirectPost(307, true);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
var x = 0;
|
||||
</script>
|
||||
<!-- This script's URI is:
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'data:text/plain,aaa', false);
|
||||
xhr.send();
|
||||
x=1;
|
||||
-->
|
||||
<script defer src="data:application/javascript,var%20x%20=%200;%20var%20xhr%20=%20new%20XMLHttpRequest();%20xhr.open('GET',%20'data:text/plain,aaa',%20false);%20xhr.send();%20x=1"></script>
|
||||
|
||||
<!-- This script's URI is:
|
||||
parent.postMessage(x, '*');
|
||||
-->
|
||||
<script defer src="data:application/javascript,parent.postMessage(x, '*');"></script>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Check that a sync XHR in a defer script blocks later defer scripts from running</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<!--
|
||||
We run the test in a subframe, because something in the testharness stuff
|
||||
interferes with defer scripts -->
|
||||
<script>
|
||||
var t = async_test();
|
||||
onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data, 1);
|
||||
});
|
||||
</script>
|
||||
<iframe src="xmlhttprequest-sync-block-defer-scripts-subframe.html"></iframe>
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Check that while a sync XHR is in flight async script loads don't complete and run script</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<body>
|
||||
<script>
|
||||
var scriptRan = false;
|
||||
var onloadFired = false;
|
||||
test(function() {
|
||||
var s = document.createElement("script");
|
||||
s.src = "data:application/javascript,scriptRan = true;";
|
||||
s.onload = function() { onloadFired = true; }
|
||||
document.body.appendChild(s);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "data:,", false);
|
||||
xhr.send();
|
||||
assert_false(scriptRan, "Script should not have run");
|
||||
assert_false(onloadFired, "load event for <script> should not have fired");
|
||||
});
|
||||
</script>
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue