Update web-platform-tests to revision 66c4613f823c4384c78ada77346eda17bb128947

This commit is contained in:
Ms2ger 2016-03-15 15:55:36 +01:00
parent 183772583f
commit a91433f0c8
234 changed files with 4368 additions and 967 deletions

View file

@ -9,21 +9,6 @@
</head>
<body>
<div id="log"></div>
<script>
var test = async_test()
test.step(function() {
var client = new XMLHttpRequest()
client.open("GET", "...")
client.onreadystatechange = function() {
test.step(function() {
assert_unreached()
})
}
client.abort()
assert_equals(client.readyState, 0)
assert_throws("InvalidStateError", function() { client.send("test") }, "calling send() after abort()")
})
test.done()
</script>
<script src="abort-during-open.js"></script>
</body>
</html>

View file

@ -0,0 +1,14 @@
var test = async_test()
test.step(function() {
var client = new XMLHttpRequest()
client.open("GET", "...")
client.onreadystatechange = function() {
test.step(function() {
assert_unreached()
})
}
client.abort()
assert_equals(client.readyState, 0)
assert_throws("InvalidStateError", function() { client.send("test") }, "calling send() after abort()")
})
test.done()

View file

@ -0,0 +1,3 @@
importScripts("/resources/testharness.js");
importScripts("abort-during-open.js");
done();

View file

@ -0,0 +1,20 @@
import imp
import os
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",
"authentication.py"))
if request.method == "OPTIONS":
return ""
else:
return auth.main(request, response)

View file

@ -0,0 +1,20 @@
import imp
import os
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",
"authentication.py"))
if request.method == "OPTIONS":
return ""
else:
return auth.main(request, response)

View file

@ -0,0 +1,10 @@
import imp
import os
here = os.path.split(os.path.abspath(__file__))[0]
def main(request, response):
auth = imp.load_source("", os.path.join(here,
"..",
"authentication.py"))
return auth.main(request, response)

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>XMLHttpRequest: send() - "Basic" authenticated request using setRequestHeader() and open() arguments (asserts header wins)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<!-- These spec references do not make much sense simply because the spec doesn't say very much about this.. -->
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="following::ol[1]/li[6]" />
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::code[contains(@title,'http-authorization')]/.." />
</head>
<body>
<div id="log"></div>
<script>
var test = async_test()
test.step(function() {
var client = new XMLHttpRequest(),
urlstart = location.host + location.pathname.replace(/\/[^\/]*$/, '/'),
user = token()
client.open("GET", location.protocol+'//'+urlstart + "resources/auth9/auth.py", false, 'open-' + user, 'open-pass')
client.setRequestHeader("x-user", user)
client.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":pass"))
client.onreadystatechange = function () {
if (client.readyState < 4) {return}
test.step( function () {
assert_equals(client.responseText, user + '\npass')
assert_equals(client.status, 200)
assert_equals(client.getResponseHeader('x-challenge'), 'DID-NOT')
test.done()
})
}
client.send(null)
})
</script>
</body>
</html>

View file

@ -0,0 +1,61 @@
<!doctype html>
<html>
<head>
<title>XMLHttpRequest: send() - "Basic" authenticated CORS request using setRequestHeader() but not setting withCredentials (expects to succeed)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<!-- These spec references do not make much sense simply because the spec doesn't say very much about this.. -->
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="following::ol[1]/li[6]" />
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::code[contains(@title,'http-authorization')]/.." />
</head>
<body>
<div id="log"></div>
<script>
function doTest(desc, pathsuffix, conditionsFunc, errorFunc, endFunc) {
var test = async_test(desc)
test.step(function() {
var client = new XMLHttpRequest(),
urlstart = location.host + location.pathname.replace(/\/[^\/]*$/, '/'),
user = token()
client.open("GET", location.protocol + "//www1." + urlstart + "resources/" + pathsuffix, false)
client.setRequestHeader("x-user", user)
client.setRequestHeader("x-pass", 'pass')
client.setRequestHeader("Authorization", "Basic " + btoa(user + ":pass"))
client.onerror = test.step_func(errorFunc)
client.onreadystatechange = test.step_func(function () {
if(client.readyState < 4) {return}
conditionsFunc(client, test, user)
})
if(endFunc) {
client.onloadend = test.step_func(endFunc)
}
client.send(null)
})
}
doTest("CORS request with setRequestHeader auth to URL accepting Authorization header", "auth7/corsenabled.py", function (client, test, user) {
assert_true(client.responseText == (user + "\npass"), "responseText should contain the right user and password")
assert_equals(client.status, 200)
assert_equals(client.getResponseHeader("x-challenge"), "DID-NOT")
test.done()
}, function(){
assert_unreached("Cross-domain request is permitted and should not cause an error")
this.done()
})
var errorFired = false;
doTest("CORS request with setRequestHeader auth to URL NOT accepting Authorization header", "auth8/corsenabled-no-authorize.py", function (client, test, user) {
assert_equals(client.responseText, '')
assert_equals(client.status, 0)
}, function(e){
errorFired = true
assert_equals(e.type, 'error', 'Error event fires when Authorize is a user-set header but not allowed by the CORS endpoint')
}, function() {
assert_true(errorFired, 'The error event should fire')
this.done()
})
</script>
</body>
</html>

View file

@ -8,14 +8,6 @@
</head>
<body>
<div id="log"></div>
<script>
test(function() {
var client = new XMLHttpRequest()
client.open("GET", "resources/well-formed.xml")
client.send(null)
assert_throws("InvalidStateError", function() { client.send(null) })
client.abort()
})
</script>
<script src="send-send.js"></script>
</body>
</html>

View file

@ -0,0 +1,7 @@
test(function() {
var client = new XMLHttpRequest()
client.open("GET", "resources/well-formed.xml")
client.send(null)
assert_throws("InvalidStateError", function() { client.send(null) })
client.abort()
})

View file

@ -0,0 +1,3 @@
importScripts("/resources/testharness.js");
importScripts("send-send.js");
done();