mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Update web-platform-tests to revision e03a9b1341ae9bdb1e4fa03765257b84d26fe2f1
This commit is contained in:
parent
7d05c76d18
commit
20a833eb75
5167 changed files with 4696 additions and 297370 deletions
|
@ -9,20 +9,18 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var test = async_test()
|
||||
test.step(function() {
|
||||
async_test(test => {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 4] // open() -> 1, send() -> 4
|
||||
client.onreadystatechange = function() {
|
||||
test.step(function() {
|
||||
result.push(client.readyState)
|
||||
})
|
||||
}
|
||||
client.onreadystatechange = test.step_func(function() {
|
||||
result.push(client.readyState)
|
||||
})
|
||||
client.open("GET", "resources/well-formed.xml", false)
|
||||
client.send(null)
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 200)
|
||||
assert_equals(client.statusText, "OK")
|
||||
assert_equals(client.responseXML.documentElement.localName, "html")
|
||||
client.abort()
|
||||
assert_equals(client.readyState, 0)
|
||||
|
@ -32,7 +30,61 @@
|
|||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
assert_array_equals(result, expected)
|
||||
test.done()
|
||||
})
|
||||
}, document.title + " (sync)")
|
||||
|
||||
async_test(test => {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 4] // open() -> 1, send() -> 4
|
||||
client.onreadystatechange = test.step_func(function() {
|
||||
result.push(client.readyState);
|
||||
if (client.readyState === 4) {
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 200)
|
||||
assert_equals(client.statusText, "OK")
|
||||
assert_equals(client.responseXML.documentElement.localName, "html")
|
||||
client.abort();
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
test.done()
|
||||
}
|
||||
})
|
||||
client.open("GET", "resources/well-formed.xml", false)
|
||||
client.send(null)
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 200)
|
||||
assert_equals(client.statusText, "OK")
|
||||
assert_equals(client.responseXML.documentElement.localName, "html")
|
||||
}, document.title + " (sync aborted in readystatechange)")
|
||||
|
||||
async_test(test => {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 2, 3, 4]
|
||||
client.onreadystatechange = test.step_func(function() {
|
||||
result.push(client.readyState);
|
||||
if (client.readyState === 4) {
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 200)
|
||||
assert_equals(client.responseXML.documentElement.localName, "html")
|
||||
client.abort();
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
setTimeout(function() {
|
||||
assert_array_equals(result, expected)
|
||||
test.done();
|
||||
}, 100); // wait a bit in case XHR timeout causes spurious event
|
||||
}
|
||||
})
|
||||
client.open("GET", "resources/well-formed.xml")
|
||||
client.send(null)
|
||||
}, document.title + " (async)")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: abort() during HEADERS_RECEIVED</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4] following-sibling::ol/li[5]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(test => {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 2, 4]
|
||||
client.onreadystatechange = test.step_func(function() {
|
||||
result.push(client.readyState);
|
||||
if (client.readyState === 2) {
|
||||
assert_equals(client.status, 200)
|
||||
assert_equals(client.statusText, "OK")
|
||||
assert_equals(client.responseXML, null)
|
||||
client.abort();
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
}
|
||||
if (client.readyState === 4) {
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
}
|
||||
})
|
||||
client.onloadend = test.step_func(function() {
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
setTimeout(function() {
|
||||
assert_array_equals(result, expected)
|
||||
test.done();
|
||||
}, 100); // wait a bit in case XHR timeout causes spurious event
|
||||
})
|
||||
client.open("GET", "resources/well-formed.xml")
|
||||
client.send(null)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,54 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: abort() during LOADING</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4] following-sibling::ol/li[5]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(test => {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 2, 3, 4]
|
||||
client.onreadystatechange = test.step_func(function() {
|
||||
result.push(client.readyState);
|
||||
if (client.readyState === 3) {
|
||||
assert_equals(client.status, 200)
|
||||
assert_equals(client.statusText, "OK")
|
||||
assert_equals(client.responseXML, null)
|
||||
client.abort();
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
}
|
||||
if (client.readyState === 4) {
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
}
|
||||
})
|
||||
client.onloadend = test.step_func(function() {
|
||||
assert_equals(client.readyState, 4)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
setTimeout(function() {
|
||||
assert_array_equals(result, expected)
|
||||
test.done();
|
||||
}, 100); // wait a bit in case XHR timeout causes spurious event
|
||||
})
|
||||
client.open("GET", "resources/well-formed.xml")
|
||||
client.send(null)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -8,7 +8,11 @@ test.step(function() {
|
|||
})
|
||||
}
|
||||
assert_equals(client.readyState, 1, "before abort()")
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
client.abort()
|
||||
assert_equals(client.readyState, 1, "after abort()")
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
})
|
||||
test.done()
|
||||
|
|
|
@ -17,8 +17,13 @@
|
|||
assert_unreached()
|
||||
})
|
||||
}
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
client.abort()
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
})
|
||||
test.done()
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ProgressEvent: firing events for HTTP with Content-Length</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#firing-events-using-the-progressevent-interface">
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var test = async_test();
|
||||
|
||||
test.step(function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.onprogress = function(pe) {
|
||||
test.step(function() {
|
||||
if(pe.type == "progress") {
|
||||
assert_greater_than_equal(pe.loaded, 0, "loaded");
|
||||
assert_true(pe.lengthComputable, "lengthComputable");
|
||||
assert_equals(pe.total, 1300, "total");
|
||||
}
|
||||
}, "Check lengthComputed, loaded, total when Content-Length is given.");
|
||||
}
|
||||
|
||||
// "loadstart", "error", "abort", "load" tests are out of scope.
|
||||
// They SHOULD be tested in each spec that implement ProgressEvent.
|
||||
|
||||
xhr.onloadend = function(pe) {
|
||||
test.done();
|
||||
}
|
||||
xhr.open("GET", "resources/trickle.py?ms=0&count=100&specifylength=1", true);
|
||||
xhr.send(null);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ProgressEvent: firing events for HTTP with no Content-Length</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#firing-events-using-the-progressevent-interface">
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var test = async_test();
|
||||
|
||||
test.step(function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.onprogress = function(pe) {
|
||||
test.step(function() {
|
||||
if(pe.type == "progress") {
|
||||
assert_greater_than_equal(pe.loaded, 0, "loaded");
|
||||
assert_false(pe.lengthComputable, "lengthComputable");
|
||||
assert_equals(pe.total, 0, "total");
|
||||
}
|
||||
}, "Check lengthComputed, loaded, total when Content-Length is NOT given.");
|
||||
}
|
||||
|
||||
// "loadstart", "error", "abort", "load" tests are out of scope.
|
||||
// They SHOULD be tested in each spec that implement ProgressEvent.
|
||||
|
||||
xhr.onloadend = function(pe) {
|
||||
test.done();
|
||||
}
|
||||
xhr.open("GET", "resources/trickle.py?ms=0&count=100", true);
|
||||
xhr.send(null);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
0
tests/wpt/web-platform-tests/XMLHttpRequest/open-during-abort.htm
Executable file → Normal file
0
tests/wpt/web-platform-tests/XMLHttpRequest/open-during-abort.htm
Executable file → Normal file
|
@ -0,0 +1,47 @@
|
|||
<!doctype html>
|
||||
<title>ProgressEvent constructor</title>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#interface-progressevent">
|
||||
<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-constructor">
|
||||
<link rel="help" href="https://dom.spec.whatwg.org/#interface-event">
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var ev = new ProgressEvent("test")
|
||||
assert_equals(ev.type, "test")
|
||||
assert_equals(ev.target, null)
|
||||
assert_equals(ev.currentTarget, null)
|
||||
assert_equals(ev.eventPhase, Event.NONE)
|
||||
assert_equals(ev.bubbles, false)
|
||||
assert_equals(ev.cancelable, false)
|
||||
assert_equals(ev.defaultPrevented, false)
|
||||
assert_equals(ev.isTrusted, false)
|
||||
assert_true(ev.timeStamp > 0)
|
||||
assert_true("initEvent" in ev)
|
||||
assert_equals(ev.lengthComputable, false)
|
||||
assert_equals(ev.loaded, 0)
|
||||
assert_equals(ev.total, 0)
|
||||
}, "Default event values.")
|
||||
test(function() {
|
||||
var ev = new ProgressEvent("test")
|
||||
assert_equals(ev["initProgressEvent"], undefined)
|
||||
}, "There must not be a initProgressEvent().")
|
||||
test(function() {
|
||||
var ev = new ProgressEvent("I am an event", { type: "trololol", bubbles: true, cancelable: false})
|
||||
assert_equals(ev.type, "I am an event")
|
||||
assert_equals(ev.bubbles, true)
|
||||
assert_equals(ev.cancelable, false)
|
||||
}, "Basic test.")
|
||||
test(function() {
|
||||
var ev = new ProgressEvent(null, { lengthComputable: "hah", loaded: "2" })
|
||||
assert_equals(ev.type, "null")
|
||||
assert_equals(ev.lengthComputable, true)
|
||||
assert_equals(ev.loaded, 2)
|
||||
}, "ECMAScript value conversion test.")
|
||||
test(function() {
|
||||
var ev = new ProgressEvent("Xx", { lengthcomputable: true})
|
||||
assert_equals(ev.type, "Xx")
|
||||
assert_equals(ev.lengthComputable, false)
|
||||
}, "ProgressEventInit members must be matched case-sensitively.")
|
||||
</script>
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<title>The ProgressEvent interface</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_equals(typeof ProgressEvent, "function")
|
||||
assert_equals(ProgressEvent.length, 1)
|
||||
})
|
||||
test(function() {
|
||||
var desc = Object.getOwnPropertyDescriptor(ProgressEvent, "prototype")
|
||||
assert_equals(desc.value, ProgressEvent.prototype)
|
||||
assert_equals(desc.writable, false)
|
||||
assert_equals(desc.enumerable, false)
|
||||
assert_equals(desc.configurable, false)
|
||||
assert_throws(new TypeError(), function() {
|
||||
"use strict";
|
||||
delete ProgressEvent.prototype;
|
||||
})
|
||||
assert_equals(ProgressEvent.prototype.constructor, ProgressEvent)
|
||||
assert_equals(Object.getPrototypeOf(ProgressEvent.prototype), Event.prototype)
|
||||
}, "interface prototype object")
|
||||
var attributes = [
|
||||
["boolean", "lengthComputable"],
|
||||
["unsigned long long", "loaded"],
|
||||
["unsigned long long", "total"]
|
||||
];
|
||||
attributes.forEach(function(a) {
|
||||
test(function() {
|
||||
var desc = Object.getOwnPropertyDescriptor(ProgressEvent.prototype, a[1])
|
||||
assert_equals(desc.enumerable, true)
|
||||
assert_equals(desc.configurable, true)
|
||||
assert_throws(new TypeError(), function() {
|
||||
ProgressEvent.prototype[a[1]]
|
||||
})
|
||||
})
|
||||
})
|
||||
test(function() {
|
||||
for (var p in window) {
|
||||
assert_not_equals(p, "ProgressEvent")
|
||||
}
|
||||
}, "Interface objects properties should not be Enumerable")
|
||||
test(function() {
|
||||
assert_true(!!window.ProgressEvent, "Interface should exist.")
|
||||
assert_true(delete window.ProgressEvent, "The delete operator should return true.")
|
||||
assert_equals(window.ProgressEvent, undefined, "Interface should be gone.")
|
||||
}, "Should be able to delete ProgressEvent.")
|
||||
</script>
|
0
tests/wpt/web-platform-tests/XMLHttpRequest/send-content-type-charset.htm
Executable file → Normal file
0
tests/wpt/web-platform-tests/XMLHttpRequest/send-content-type-charset.htm
Executable file → Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<meta charset="utf-8">
|
||||
<title>Synchronous XMLHttpRequest Feature Policy Test</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=/feature-policy/resources/featurepolicy.js></script>
|
||||
<script src=util/utils.js></script>
|
||||
<script>
|
||||
'use strict';
|
||||
run_all_fp_tests_allow_all(
|
||||
'http://{{domains[www]}}:{{ports[http][0]}}',
|
||||
'sync-xhr',
|
||||
'InvalidAccessError: Failed to execute \'open\' on \'XMLHttpRequest\': ' +
|
||||
'Synchronous requests are disabled by Feature Policy.',
|
||||
() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "data:,", false);
|
||||
xhr.send();
|
||||
resolve();
|
||||
} catch(e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue