mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Update web-platform-tests to revision 44702f2bc8ea98bc32b5b244f2fe63c6ce66d49d
This commit is contained in:
parent
85fa6409bb
commit
c227604a2c
997 changed files with 45660 additions and 14650 deletions
|
@ -76,7 +76,7 @@
|
|||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
setTimeout(function() {
|
||||
test.step_timeout(function() {
|
||||
assert_array_equals(result, expected)
|
||||
test.done();
|
||||
}, 100); // wait a bit in case XHR timeout causes spurious event
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
setTimeout(function() {
|
||||
test.step_timeout(function() {
|
||||
assert_array_equals(result, expected)
|
||||
test.done();
|
||||
}, 100); // wait a bit in case XHR timeout causes spurious event
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
setTimeout(function() {
|
||||
test.step_timeout(function() {
|
||||
assert_array_equals(result, expected)
|
||||
test.done();
|
||||
}, 100); // wait a bit in case XHR timeout causes spurious event
|
||||
|
@ -51,4 +51,3 @@
|
|||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>Casing of known headers</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const client = new XMLHttpRequest
|
||||
client.open("GET", "resources/header-content-length.asis", false)
|
||||
client.send()
|
||||
assert_equals(client.getAllResponseHeaders(), "content-length: 0\r\n")
|
||||
})
|
||||
test(() => {
|
||||
const client = new XMLHttpRequest
|
||||
client.open("GET", "resources/echo-headers.py", false)
|
||||
client.setRequestHeader("THIS-IS-A-TEST", "1")
|
||||
client.setRequestHeader("THIS-is-A-test", "2")
|
||||
client.setRequestHeader("content-TYPE", "x/x")
|
||||
client.send()
|
||||
assert_regexp_match(client.responseText, /content-TYPE/)
|
||||
assert_regexp_match(client.responseText, /THIS-IS-A-TEST: 1, 2/)
|
||||
})
|
||||
promise_test(() => {
|
||||
return fetch("resources/echo-headers.py", {headers: [["THIS-is-A-test", 1], ["THIS-IS-A-TEST", 2]] }).then(res => res.text()).then(body => {
|
||||
assert_regexp_match(body, /THIS-is-A-test: 1, 2/)
|
||||
})
|
||||
})
|
||||
</script>
|
|
@ -9,27 +9,22 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var test = async_test()
|
||||
test.step(function() {
|
||||
async_test(function() {
|
||||
var client = new XMLHttpRequest()
|
||||
var headersUnsent = client.getAllResponseHeaders();
|
||||
test.step(function() {
|
||||
assert_equals(headersUnsent, "")
|
||||
});
|
||||
client.onreadystatechange = function() {
|
||||
test.step(function() {
|
||||
var headers = client.getAllResponseHeaders().toLowerCase()
|
||||
if(client.readyState == 1) {
|
||||
assert_equals(headers, "")
|
||||
}
|
||||
if(client.readyState > 1) {
|
||||
assert_false(headers.indexOf("200 ok") != -1)
|
||||
assert_false(headers.indexOf("http/1.") != -1)
|
||||
}
|
||||
if(client.readyState == 4)
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
|
||||
client.onreadystatechange = this.step_func(function() {
|
||||
var headers = client.getAllResponseHeaders().toLowerCase()
|
||||
if(client.readyState == 1) {
|
||||
assert_equals(headers, "")
|
||||
}
|
||||
if(client.readyState > 1) {
|
||||
assert_false(headers.indexOf("200 ok") != -1)
|
||||
assert_false(headers.indexOf("http/1.") != -1)
|
||||
}
|
||||
if(client.readyState == 4)
|
||||
this.done()
|
||||
})
|
||||
client.open("GET", "resources/headers.py")
|
||||
client.send(null)
|
||||
})
|
||||
|
|
|
@ -9,6 +9,7 @@ async_test((t) => {
|
|||
client.onload = t.step_func_done(() => {
|
||||
assert_equals(client.getAllResponseHeaders(), "foo-test: 1, 2, 3\r\n")
|
||||
})
|
||||
client.onerror = t.unreached_func("unexpected error")
|
||||
client.open("GET", "resources/headers-basic.asis")
|
||||
client.send(null)
|
||||
})
|
||||
|
@ -18,7 +19,15 @@ async_test((t) => {
|
|||
client.onload = t.step_func_done(() => {
|
||||
assert_equals(client.getAllResponseHeaders(), "also-here: Mr. PB\r\newok: lego\r\nfoo-test: 1, 2\r\n")
|
||||
})
|
||||
client.onerror = t.unreached_func("unexpected error")
|
||||
client.open("GET", "resources/headers.asis")
|
||||
client.send(null)
|
||||
})
|
||||
|
||||
test(() => {
|
||||
const client = new XMLHttpRequest
|
||||
client.open("GET", "resources/header-content-length.asis", false)
|
||||
client.send()
|
||||
assert_equals(client.getAllResponseHeaders(), "content-length: 0\r\n")
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
test.step(function() {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 4, 1] // open() -> 1,
|
||||
expected = [1, 4, 1] // open() -> 1,
|
||||
// abort() -> 4, open() -> 1
|
||||
client.onreadystatechange = function() {
|
||||
test.step(function() {
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/content.py?\u00DF", false) // This is the German "eszett" character
|
||||
client.send()
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "%C3%9F")
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "%DF")
|
||||
}, "percent encode characters");
|
||||
test(function() {
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/content.py?\uD83D", false)
|
||||
client.send()
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "%EF%BF%BD")
|
||||
}, "lone surrogate should return U+FFFD");
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "&%2365533;")
|
||||
}, "lone surrogate");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
test(function() {
|
||||
var client = new self[0].XMLHttpRequest()
|
||||
document.body.removeChild(document.getElementsByTagName("iframe")[0])
|
||||
assert_throws("InvalidStateError", function() {
|
||||
client.open("GET", "folder.txt")
|
||||
assert_throws("InvalidStateError", function() {
|
||||
client.open("GET", "folder.txt")
|
||||
}, "open() when associated document's IFRAME is removed")
|
||||
})
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
var client = new self[0].XMLHttpRequest()
|
||||
client.open("GET", "folder.txt")
|
||||
document.body.removeChild(document.getElementsByTagName("iframe")[0])
|
||||
assert_throws("InvalidStateError", function() {
|
||||
assert_throws("InvalidStateError", function() {
|
||||
client.send(null)
|
||||
}, "send() when associated document's IFRAME is removed")
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/*
|
||||
It's unclear what the pass condition should be for this test.
|
||||
Implementations:
|
||||
Firefox, Opera (Presto): terminate request with no further events when IFRAME is removed.
|
||||
Firefox, Opera (Presto): terminate request with no further events when IFRAME is removed.
|
||||
Chrome: completes request to readyState=4 but responseText is "" so it's pretty much terminated with an extra event for "DONE" state
|
||||
Pass condition is now according to my suggested spec text in https://github.com/whatwg/xhr/pull/3 , if that's not accepted we'll have to amend this test
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@
|
|||
test.step(function() {
|
||||
var hasErrorEvent = false
|
||||
var client = new self[0].XMLHttpRequest()
|
||||
client.onreadystatechange = function() {
|
||||
client.onreadystatechange = function() {
|
||||
test.step(function() {
|
||||
if(client.readyState == 4) {
|
||||
assert_equals(client.responseText, "", "responseText is empty on inactive document error condition")
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
ifr.onload = function() {
|
||||
// Again, do things async so we're not doing loads from inside
|
||||
// load events.
|
||||
setTimeout(function() {
|
||||
test.step_timeout(function() {
|
||||
client = new ifr.contentWindow.XMLHttpRequest();
|
||||
count++;
|
||||
// Important to do a normal navigation, not a reload.
|
||||
|
|
|
@ -1,43 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>XMLHttpRequest: redirected worker scripts, origin and referrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
var test = async_test() // This "test" does not actually do any assertations. It's just there to have multiple, separate, asyncronous sub-tests.
|
||||
var expectations = {
|
||||
'Referer header': 'Referer: '+(location.href.replace(/[^/]*$/, ''))+"resources/workerxhr-origin-referrer.js\n",
|
||||
'Origin header': 'Origin: '+location.protocol+'//'+location.hostname+((location.port === "")?"":":"+location.port)+'\n',
|
||||
'Request URL test' : (location.href.replace(/[^/]*$/, ''))+'resources/requri.py?full'
|
||||
}
|
||||
// now start the worker
|
||||
var finalWorkerURL = "workerxhr-origin-referrer.js";
|
||||
var url = "resources/redirect.py?location=" + encodeURIComponent(finalWorkerURL);
|
||||
var worker = new Worker(url)
|
||||
worker.onmessage = function (e) {
|
||||
var subtest = async_test(e.data.test)
|
||||
subtest.step(function(){
|
||||
var thisExpectation = expectations[e.data.test]
|
||||
delete expectations[e.data.test]
|
||||
assert_equals(e.data.result, thisExpectation)
|
||||
subtest.done()
|
||||
})
|
||||
var allDone = true
|
||||
for(var prop in expectations){
|
||||
allDone = false
|
||||
}
|
||||
if(allDone){
|
||||
test.step(function(){
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>XMLHttpRequest: redirected worker scripts, origin and referrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var finalWorkerURL = "workerxhr-origin-referrer.js";
|
||||
var url = "resources/redirect.py?location=" + encodeURIComponent(finalWorkerURL);
|
||||
fetch_tests_from_worker(new Worker(url));
|
||||
</script>
|
||||
|
|
|
@ -1,43 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>XMLHttpRequest: worker scripts, origin and referrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::OL[1]/LI[3] following::OL[1]/LI[3]/ol[1]/li[1] following::OL[1]/LI[3]/ol[1]/li[2] following::OL[1]/LI[3]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
var test = async_test() // This "test" does not actually do any assertations. It's just there to have multiple, separate, asyncronous sub-tests.
|
||||
var expectations = {
|
||||
'Referer header': 'Referer: '+(location.href.replace(/[^/]*$/, ''))+"resources/workerxhr-origin-referrer.js\n",
|
||||
'Origin header': 'Origin: '+location.protocol+'//'+location.hostname+((location.port === "")?"":":"+location.port)+'\n',
|
||||
'Request URL test' : (location.href.replace(/[^/]*$/, ''))+'resources/requri.py?full'
|
||||
}
|
||||
// now start the worker
|
||||
var worker = new Worker("resources/workerxhr-origin-referrer.js")
|
||||
worker.onmessage = function (e) {
|
||||
var subtest = async_test(e.data.test)
|
||||
subtest.step(function(){
|
||||
var thisExpectation = expectations[e.data.test]
|
||||
delete expectations[e.data.test]
|
||||
assert_equals(e.data.result, thisExpectation)
|
||||
subtest.done()
|
||||
})
|
||||
var allDone = true
|
||||
for(var prop in expectations){
|
||||
allDone = false
|
||||
}
|
||||
if(allDone){
|
||||
test.step(function(){
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>XMLHttpRequest: worker scripts, origin and referrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
fetch_tests_from_worker(new Worker("resources/workerxhr-origin-referrer.js"));
|
||||
</script>
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
var client = new XMLHttpRequest();
|
||||
client.onreadystatechange = function() {
|
||||
if (client.readyState !== 4) return;
|
||||
try{
|
||||
try{
|
||||
var str = client.responseXML.documentElement.tagName+client.responseXML.documentElement.firstChild.tagName+client.responseXML.documentElement.firstChild.textContent;
|
||||
}catch(e){
|
||||
assert_unreached('Exception when reading responseXML');
|
||||
}
|
||||
}catch(e){
|
||||
assert_unreached('Exception when reading responseXML');
|
||||
}
|
||||
assert_equals( client.responseXML.documentElement.tagName, 'test' );
|
||||
assert_equals( client.responseXML.documentElement.firstChild.tagName, 'message' );
|
||||
assert_equals( client.responseXML.documentElement.firstChild.textContent, 'Hello World!' );
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import imp
|
||||
import os
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
|
||||
def main(request, response):
|
||||
response.headers.set('Access-Control-Allow-Origin', request.headers.get("origin"));
|
||||
response.headers.set('Access-Control-Allow-Credentials', 'true');
|
||||
response.headers.set('Access-Control-Allow-Methods', 'GET');
|
||||
response.headers.set('Access-Control-Allow-Headers', 'authorization, x-user, x-pass');
|
||||
response.headers.set('Access-Control-Expose-Headers', 'x-challenge, xhr-user, ses-user');
|
||||
auth = imp.load_source("", os.path.abspath("XMLHttpRequest/resources/authentication.py"))
|
||||
auth = imp.load_source("", os.path.abspath(os.path.join(here, os.pardir, "authentication.py")))
|
||||
if request.method == "OPTIONS":
|
||||
return ""
|
||||
else:
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import imp
|
||||
import os
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
def main(request, response):
|
||||
response.headers.set('Access-Control-Allow-Origin', request.headers.get("origin"));
|
||||
response.headers.set('Access-Control-Allow-Credentials', 'true');
|
||||
response.headers.set('Access-Control-Allow-Methods', 'GET');
|
||||
response.headers.set('Access-Control-Allow-Headers', 'authorization, x-user, x-pass');
|
||||
response.headers.set('Access-Control-Expose-Headers', 'x-challenge, xhr-user, ses-user');
|
||||
auth = imp.load_source("", os.path.join(os.path.abspath(os.curdir),
|
||||
"XMLHttpRequest",
|
||||
"resources",
|
||||
auth = imp.load_source("", os.path.join(here,
|
||||
os.pardir,
|
||||
"authentication.py"))
|
||||
if request.method == "OPTIONS":
|
||||
return ""
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import imp
|
||||
import os
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
|
||||
def main(request, response):
|
||||
response.headers.set('Access-Control-Allow-Origin', request.headers.get("origin"));
|
||||
response.headers.set('Access-Control-Allow-Credentials', 'true');
|
||||
response.headers.set('Access-Control-Allow-Methods', 'GET');
|
||||
response.headers.set('Access-Control-Allow-Headers', 'x-user, x-pass');
|
||||
response.headers.set('Access-Control-Expose-Headers', 'x-challenge, xhr-user, ses-user');
|
||||
auth = imp.load_source("", os.path.join(os.path.abspath(os.curdir),
|
||||
"XMLHttpRequest",
|
||||
"resources",
|
||||
auth = imp.load_source("", os.path.join(here,
|
||||
os.pardir,
|
||||
"authentication.py"))
|
||||
if request.method == "OPTIONS":
|
||||
return ""
|
||||
|
|
|
@ -1,34 +1,63 @@
|
|||
// This simply posts a message to the owner page with the contents of the Referer header
|
||||
var xhr=new XMLHttpRequest()
|
||||
xhr.onreadystatechange = function(){
|
||||
if(xhr.readyState == 4){
|
||||
var obj = {test:'Referer header', result:xhr.responseText}
|
||||
self.postMessage(obj)
|
||||
}
|
||||
}
|
||||
xhr.open('GET', 'inspect-headers.py?filter_name=referer', true)
|
||||
xhr.send()
|
||||
importScripts("/resources/testharness.js")
|
||||
|
||||
// This simply posts a message to the owner page with the contents of the Origin header
|
||||
var xhr2=new XMLHttpRequest()
|
||||
xhr2.onreadystatechange = function(){
|
||||
if(xhr2.readyState == 4){
|
||||
var obj = {test:'Origin header', result:xhr2.responseText}
|
||||
self.postMessage(obj)
|
||||
}
|
||||
}
|
||||
xhr2.open('GET', location.protocol + '//www2.'+location.hostname+((location.port === "")?"":":"+location.port)+(location.pathname.replace(/[^/]*$/, ''))+'inspect-headers.py?filter_name=origin&cors', true)
|
||||
xhr2.send()
|
||||
async_test(function() {
|
||||
var expected = 'Referer: ' +
|
||||
location.href.replace(/[^/]*$/, '') +
|
||||
"workerxhr-origin-referrer.js\n"
|
||||
|
||||
// If "origin" / base URL is the origin of this JS file, we can load files
|
||||
// from the server it originates from.. and requri.py will be able to tell us
|
||||
// what the requested URL was
|
||||
var xhr3=new XMLHttpRequest()
|
||||
xhr3.onreadystatechange = function(){
|
||||
if(xhr3.readyState == 4){
|
||||
var obj = {test:'Request URL test', result:xhr3.responseText}
|
||||
self.postMessage(obj)
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.onreadystatechange = this.step_func(function() {
|
||||
if (xhr.readyState == 4) {
|
||||
assert_equals(xhr.responseText, expected)
|
||||
this.done()
|
||||
}
|
||||
}
|
||||
xhr3.open('GET', 'requri.py?full', true)
|
||||
xhr3.send()
|
||||
})
|
||||
xhr.open('GET', 'inspect-headers.py?filter_name=referer', true)
|
||||
xhr.send()
|
||||
}, 'Referer header')
|
||||
|
||||
async_test(function() {
|
||||
var expected = 'Origin: ' +
|
||||
location.protocol +
|
||||
'//' +
|
||||
location.hostname +
|
||||
(location.port === "" ? "" : ":" + location.port) +
|
||||
'\n'
|
||||
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.onreadystatechange = this.step_func(function() {
|
||||
if (xhr.readyState == 4) {
|
||||
assert_equals(xhr.responseText, expected)
|
||||
this.done()
|
||||
}
|
||||
})
|
||||
var url = location.protocol +
|
||||
'//www2.' +
|
||||
location.hostname +
|
||||
(location.port === "" ? "" : ":" + location.port) +
|
||||
location.pathname.replace(/[^/]*$/, '') +
|
||||
'inspect-headers.py?filter_name=origin&cors'
|
||||
xhr.open('GET', url, true)
|
||||
xhr.send()
|
||||
}, 'Origin header')
|
||||
|
||||
async_test(function() {
|
||||
// If "origin" / base URL is the origin of this JS file, we can load files
|
||||
// from the server it originates from.. and requri.py will be able to tell us
|
||||
// what the requested URL was
|
||||
|
||||
var expected = location.href.replace(/[^/]*$/, '') +
|
||||
'requri.py?full'
|
||||
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.onreadystatechange = this.step_func(function() {
|
||||
if (xhr.readyState == 4) {
|
||||
assert_equals(xhr.responseText, expected)
|
||||
this.done()
|
||||
}
|
||||
})
|
||||
xhr.open('GET', 'requri.py?full', true)
|
||||
xhr.send()
|
||||
}, 'Request URL test')
|
||||
|
||||
done()
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
var xhr=new XMLHttpRequest()
|
||||
xhr.onreadystatechange = function(){
|
||||
if(xhr.readyState == 4){
|
||||
var status = xhr.responseText === 'bottom\n' ? 'PASSED' : 'FAILED'
|
||||
self.postMessage(status)
|
||||
}
|
||||
if(xhr.readyState == 4){
|
||||
var status = xhr.responseText === 'bottom\n' ? 'PASSED' : 'FAILED'
|
||||
self.postMessage(status)
|
||||
}
|
||||
}
|
||||
xhr.open('GET', 'folder.txt', true)
|
||||
xhr.send()
|
||||
|
|
|
@ -2,5 +2,5 @@ if (this.document === undefined)
|
|||
importScripts("xmlhttprequest-timeout.js");
|
||||
|
||||
runTestRequests([ new RequestTracker(true, "no time out scheduled, load fires normally", 0),
|
||||
new RequestTracker(true, "load fires normally", TIME_NORMAL_LOAD),
|
||||
new RequestTracker(true, "timeout hit before load", TIME_REGULAR_TIMEOUT) ]);
|
||||
new RequestTracker(true, "load fires normally", TIME_NORMAL_LOAD),
|
||||
new RequestTracker(true, "timeout hit before load", TIME_REGULAR_TIMEOUT) ]);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
runTestRequests([ SyncRequestSettingTimeoutAfterOpen,
|
||||
SyncRequestSettingTimeoutBeforeOpen ]);
|
||||
SyncRequestSettingTimeoutBeforeOpen ]);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
if (this.document === undefined){
|
||||
importScripts("xmlhttprequest-timeout.js");
|
||||
}else{
|
||||
throw "This test expects to be run as a Worker";
|
||||
throw "This test expects to be run as a Worker";
|
||||
}
|
||||
|
||||
/* NOT TESTED: setting timeout before calling open( ... , false) in a worker context. The test code always calls open() first. */
|
||||
|
||||
runTestRequests([ new RequestTracker(false, "no time out scheduled, load fires normally", 0),
|
||||
new RequestTracker(false, "load fires normally", TIME_NORMAL_LOAD),
|
||||
new RequestTracker(false, "timeout hit before load", TIME_REGULAR_TIMEOUT) ]);
|
||||
new RequestTracker(false, "load fires normally", TIME_NORMAL_LOAD),
|
||||
new RequestTracker(false, "timeout hit before load", TIME_REGULAR_TIMEOUT) ]);
|
||||
|
|
|
@ -2,5 +2,5 @@ if (this.document === undefined)
|
|||
importScripts("xmlhttprequest-timeout.js");
|
||||
|
||||
runTestRequests([ new RequestTracker(true, "load fires normally with no timeout set, twice", 0, TIME_REGULAR_TIMEOUT, 0),
|
||||
new RequestTracker(true, "load fires normally with same timeout set twice", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD),
|
||||
new RequestTracker(true, "timeout fires normally with same timeout set twice", TIME_REGULAR_TIMEOUT, TIME_DELAY, TIME_REGULAR_TIMEOUT) ]);
|
||||
new RequestTracker(true, "load fires normally with same timeout set twice", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD),
|
||||
new RequestTracker(true, "timeout fires normally with same timeout set twice", TIME_REGULAR_TIMEOUT, TIME_DELAY, TIME_REGULAR_TIMEOUT) ]);
|
||||
|
|
|
@ -245,7 +245,7 @@ AbortedRequest.prototype = {
|
|||
/**
|
||||
* Check the event received, and if it's the right (and only) one we get.
|
||||
*
|
||||
* WebKit fires abort events even for DONE and UNSENT states, which is
|
||||
* WebKit fires abort events even for DONE and UNSENT states, which is
|
||||
* discussed in http://webkit.org/b/98404
|
||||
* That's why we chose to accept secondary "abort" events in this test.
|
||||
*
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
}
|
||||
|
||||
const encoded_content = "%e6%a9%9f";
|
||||
const encoded_xml =
|
||||
const encoded_xml =
|
||||
encodeURIComponent("<?xml version='1.0' encoding='windows-1252'?><x>") + encoded_content + encodeURIComponent("<\/x>");
|
||||
const encoded_html =
|
||||
encodeURIComponent("<!doctype html><meta charset=windows-1252><x>") + encoded_content + encodeURIComponent("<\/x>");
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function request(user1, pass1, user2, pass2, name) {
|
||||
function request(user1, pass1, user2, pass2, name) {
|
||||
// user1, pass1 will if given become userinfo part of URL
|
||||
// user2, pass2 will if given be passed to open() call
|
||||
test(function() {
|
||||
|
|
|
@ -11,51 +11,82 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var expectations = [
|
||||
{ contentType: 'application/xml;charset=UTF-8', responseText : '<\u00FF\/>' },
|
||||
{ contentType: 'text/html;charset=UTF-8', responseText : '<body>\uFFFD<\/body>' }, /*invalid character code in document turns into FFFD*/
|
||||
{ contentType: 'text/html;charset=UTF-8', responseText : '<body>\u30C6\u30b9\u30c8<\/body>' } /* correctly serialized Shift-JIS */,
|
||||
{ contentType: 'text/html;charset=UTF-8', responseText: 'top' }, /* There's some markup included, but it's not really relevant for this test suite, so we do an indexOf() test */
|
||||
{ contentType: 'text/html;charset=UTF-8' },
|
||||
{ contentType: 'text/html;charset=UTF-8', responseText: '<img>foo' },
|
||||
{ contentType: 'text/html;charset=UTF-8', responseText: '<!DOCTYPE html><html><head></head><body><div></div></body></html>' }
|
||||
]
|
||||
var tests = [
|
||||
{
|
||||
title: 'XML document, windows-1252',
|
||||
url: 'resources/win-1252-xml.py',
|
||||
contentType: 'application/xml;charset=UTF-8',
|
||||
responseText: '<\u00FF\/>'
|
||||
},
|
||||
// Invalid character code in document turns into U+FFFD.
|
||||
{
|
||||
title: 'HTML document, invalid UTF-8',
|
||||
url: 'resources/invalid-utf8-html.py',
|
||||
contentType: 'text/html;charset=UTF-8',
|
||||
responseText: '<body>\uFFFD<\/body>'
|
||||
},
|
||||
// Correctly serialized Shift-JIS.
|
||||
{
|
||||
title: 'HTML document, shift-jis',
|
||||
url: 'resources/shift-jis-html.py',
|
||||
contentType: 'text/html;charset=UTF-8',
|
||||
responseText: '<body>\u30C6\u30b9\u30c8<\/body>'
|
||||
},
|
||||
// There's some markup included, but it's not really relevant for this
|
||||
// test suite, so we do an indexOf() test.
|
||||
{
|
||||
title: 'plain text file',
|
||||
url: 'folder.txt',
|
||||
contentType: 'text/html;charset=UTF-8',
|
||||
responseText: 'top'
|
||||
},
|
||||
// This test does not want to assert anything about what markup a
|
||||
// standalone image should be wrapped in. Hence this test lacks a
|
||||
// responseText expectation.
|
||||
{
|
||||
title: 'image file',
|
||||
url: 'resources/image.gif',
|
||||
contentType: 'text/html;charset=UTF-8'
|
||||
},
|
||||
{
|
||||
title: 'img tag',
|
||||
url: 'resources/img-utf8-html.py',
|
||||
contentType: 'text/html;charset=UTF-8',
|
||||
responseText: '<img>foo'
|
||||
},
|
||||
{
|
||||
title: 'empty div',
|
||||
url: 'resources/empty-div-utf8-html.py',
|
||||
contentType: 'text/html;charset=UTF-8',
|
||||
responseText: '<!DOCTYPE html><html><head></head><body><div></div></body></html>'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
function request(input, number, title) {
|
||||
test(function() {
|
||||
tests.forEach(function(t) {
|
||||
async_test(function() {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.onload = this.step_func_done(function() {
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("POST", "resources/content.py?response_charset_label=UTF-8", false)
|
||||
client.send(input)
|
||||
var exp = expectations[number]
|
||||
assert_equals(client.getResponseHeader('X-Request-Content-Type'), exp.contentType, 'document should be serialized and sent as '+exp.contentType+' (TEST#'+number+')')
|
||||
// The indexOf() assertation will overlook some stuff, i.e. XML prologues that shouldn't be there (looking at you, Presto).
|
||||
// However, arguably these things have little to do with the XHR functionality we're testing.
|
||||
if(exp.responseText){ // This test does not want to assert anything about what markup a standalone IMG should be wrapped in. Hence the GIF test lacks a responseText expectation.
|
||||
assert_true(client.responseText.indexOf(exp.responseText) != -1,
|
||||
JSON.stringify(exp.responseText) + " not in " +
|
||||
client.send(iframe.contentDocument)
|
||||
assert_equals(client.getResponseHeader('X-Request-Content-Type'),
|
||||
t.contentType,
|
||||
'document should be serialized and sent as ' + t.contentType)
|
||||
// The indexOf() assertion will overlook some stuff, e.g. XML
|
||||
// prologues that shouldn't be there (looking at you, Presto).
|
||||
// However, arguably these things have little to do with the XHR
|
||||
// functionality we're testing.
|
||||
if (t.responseText) {
|
||||
assert_true(client.responseText.indexOf(t.responseText) != -1,
|
||||
JSON.stringify(t.responseText) + " not in " +
|
||||
JSON.stringify(client.responseText));
|
||||
}
|
||||
assert_equals(client.responseXML, null)
|
||||
}, title)
|
||||
}
|
||||
function init(fr, number, title) { request(fr.contentDocument, number, title) }
|
||||
});
|
||||
iframe.src = t.url;
|
||||
document.body.appendChild(iframe);
|
||||
}, t.title);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
This test also tests how documents in various encodings are serialized.
|
||||
The below IFRAMEs contain:
|
||||
* one XML document parsed from a windows-1252 source - content is <ÿ/>
|
||||
* one HTML-document parsed from an invalid UTF-8 source, will contain a basic HTML DOM
|
||||
with a U+FFFD replacement character for the invalid char
|
||||
* one HTML document parsed from a valid Shift-JIS source
|
||||
-->
|
||||
<iframe src='resources/win-1252-xml.py' onload="init(this, 0, 'XML document, windows-1252')"></iframe>
|
||||
<iframe src='resources/invalid-utf8-html.py' onload="init(this, 1, 'HTML document, invalid UTF-8')"></iframe>
|
||||
<iframe src='resources/shift-jis-html.py' onload="init(this, 2, 'HTML document, shift-jis')"></iframe>
|
||||
<iframe src='folder.txt' onload="init(this, 3, 'plain text file')"></iframe>
|
||||
<iframe src='resources/image.gif' onload="init(this, 4, 'image file')"></iframe>
|
||||
<iframe src='resources/img-utf8-html.py' onload="init(this, 5, 'img tag')"></iframe>
|
||||
<iframe src='resources/empty-div-utf8-html.py' onload="init(this, 6, 'empty div')"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title>XMLHttpRequest: send() - non-empty data argument and GET/HEAD - async, no upload events should fire</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::OL[1]/LI[3] following::OL[1]/LI[7] following::OL[1]/LI[8]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::OL[1]/LI[3] following::OL[1]/LI[7] following::OL[1]/LI[8]" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title>XMLHttpRequest: send() - non-empty data argument and GET/HEAD</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::OL[1]/LI[3] following::OL[1]/LI[7]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::OL[1]/LI[3] following::OL[1]/LI[7]" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
test.done()
|
||||
})
|
||||
}
|
||||
client.send(null)
|
||||
client.send(null)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following::dl[1]/dt[2]" />
|
||||
<!--
|
||||
<!--
|
||||
NOTE: the XHR spec does not really handle this scenario. It's handled in the Fetch spec:
|
||||
"If response's headers do not contain a header whose name is Location, return response."
|
||||
-->
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// 307 redirects should resend the POST data, and events and headers will be a little different..
|
||||
if(shouldResendPost) {
|
||||
expectedHeaders = {
|
||||
expectedHeaders = {
|
||||
"X-Request-Content-Length": "11988",
|
||||
"X-Request-Content-Type": "text/plain;charset=UTF-8",
|
||||
"X-Request-Method": "POST",
|
||||
|
@ -45,12 +45,12 @@
|
|||
];
|
||||
} else {
|
||||
// setting the right expectations for POST resent as GET without request body
|
||||
expectedHeaders = {
|
||||
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",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title>XMLHttpRequest: setRequestHeader() after send()</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[2]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[2]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title>XMLHttpRequest: setRequestHeader() before open()</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
|
|
@ -18,6 +18,17 @@
|
|||
client.send(null)
|
||||
assert_equals(client.responseText, "x-test,")
|
||||
})
|
||||
|
||||
test(() => {
|
||||
const client = new XMLHttpRequest
|
||||
client.open("GET", "resources/echo-headers.py", false)
|
||||
client.setRequestHeader("THIS-IS-A-TEST", "1")
|
||||
client.setRequestHeader("THIS-is-A-test", "2")
|
||||
client.setRequestHeader("content-TYPE", "x/x")
|
||||
client.send()
|
||||
assert_regexp_match(client.responseText, /content-TYPE/)
|
||||
assert_regexp_match(client.responseText, /THIS-IS-A-TEST: 1, 2/)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -17,15 +17,16 @@
|
|||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var test = async_test();
|
||||
|
||||
function startRequest() {
|
||||
xhr.open("GET", "./resources/content.py?content=Hi", true);
|
||||
xhr.timeout = 2000;
|
||||
setTimeout(function () {
|
||||
test.step_timeout(function () {
|
||||
xhr.send();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
var test = async_test();
|
||||
test.step(function()
|
||||
{
|
||||
var count = 0;
|
||||
|
@ -40,7 +41,7 @@ test.step(function()
|
|||
assert_unreached("HTTP error should not timeout");
|
||||
}
|
||||
startRequest();
|
||||
setTimeout(startRequest, 3500);
|
||||
test.step_timeout(startRequest, 3500);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
<title>XMLHttpRequest: members during UNSENT</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-unsent" data-tested-assertations=".. following::dd" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-statustext-attribute" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-getresponseheader()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetext-attribute" data-tested-assertations="following::ol/li[2]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responsexml-attribute" data-tested-assertations="following::ol/li[2]" />
|
||||
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-unsent" data-tested-assertations=".. following::dd" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-statustext-attribute" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-getresponseheader()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method" data-tested-assertations="following::ol/li[1]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetext-attribute" data-tested-assertations="following::ol/li[2]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responsexml-attribute" data-tested-assertations="following::ol/li[2]" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue