Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / workers / resources / access-control-basic-get-fail-non-simple.js
blob1fc6a13a04cd4af432fdb8309c1b8a60f4672ab6
1 importScripts("worker-pre.js");
3 onmessage = function(event)
5 if (event.data == "START")
6 start();
9 function log(message)
11 postMessage("log " + message);
14 function done()
16 postMessage("DONE");
19 function start()
21 try {
22 var xhr = new XMLHttpRequest;
23 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-get-fail-non-simple.cgi", false);
24 xhr.send();
25 log("PASS: Cross-domain access allowed for simple get.");
26 } catch(e) {
27 log("FAIL: Exception thrown. Cross-domain access is not allowed in 'open'. [" + e.message + "].");
31 // This is going to fail because the cgi script is not prepared for an OPTIONS request.
32 try {
33 var xhr = new XMLHttpRequest;
34 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-get-fail-non-simple.cgi", false);
35 // Non-whitelisted method
36 xhr.setRequestHeader("x-webkit", "foobar");
37 xhr.send();
38 } catch(e) {
39 log("PASS: Exception thrown. Cross-domain access was denied in 'send'. [" + e.message + "].");
41 done();