Commit 0410d210 authored by Austin James Ahlstrom's avatar Austin James Ahlstrom Committed by Commit Bot

Porting access-control-basic-allow-async to WPT

Bug: 745385
Change-Id: I4fcee351c4fe8f639ad7c65abc83563f3afb13df
Reviewed-on: https://chromium-review.googlesource.com/590394
Commit-Queue: Austin James Ahlstrom <aahlstrom@google.com>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarTakeshi Yoshino <tyoshino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490952}
parent a579c9da
<!DOCTYPE html>
<html>
<head>
<title>Testing a basic asynchronous CORS XHR request</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<script type="text/javascript">
async_test(function(test) {
const xhr = new XMLHttpRequest;
xhr.onreadystatechange = test.step_func(function() {
if (xhr.readyState == xhr.DONE) {
assert_equals(xhr.responseText, "PASS: Cross-domain access allowed.");
test.done();
}
});
xhr.onerror = test.unreached_func("FAIL: Network error.");
xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN +
"/XMLHttpRequest/resources/access-control-basic-allow.py", true);
xhr.send();
}, "Basic async cross-origin XHR request");
</script>
</body>
</html>
<html>
<body>
<pre id='console'></pre>
<script type="text/javascript">
function log(message)
{
document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function processStateChange()
{
if (xhr.readyState == xhr.DONE) {
log(xhr.responseText);
if (window.testRunner)
testRunner.notifyDone();
}
}
function errorHandler()
{
log("FAIL: Network error.");
if (window.testRunner)
testRunner.notifyDone();
}
var xhr = new XMLHttpRequest;
xhr.onreadystatechange = processStateChange;
xhr.onerror = errorHandler;
xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-allow.cgi", true);
xhr.send();
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment