OLD | NEW |
| (Empty) |
1 <script> | |
2 chrome.test.getConfig(function(config) { | |
3 | |
4 function doReq(domain, expectSuccess) { | |
5 var req = new XMLHttpRequest(); | |
6 var url = domain + ":PORT/files/extensions/test_file.txt"; | |
7 url = url.replace(/PORT/, config.testServer.port); | |
8 | |
9 chrome.test.log("Requesting url: " + url); | |
10 req.open("GET", url, true); | |
11 | |
12 | |
13 if (expectSuccess) { | |
14 req.onload = function() { | |
15 chrome.test.assertEq(200, req.status); | |
16 chrome.test.assertEq("Hello!", req.responseText); | |
17 chrome.test.runNextTest(); | |
18 } | |
19 req.onerror = function() { | |
20 chrome.test.log("status: " + req.status); | |
21 chrome.test.log("text: " + req.responseText); | |
22 chrome.test.fail("Unexpected error for domain: " + domain); | |
23 } | |
24 } else { | |
25 req.onload = function() { | |
26 chrome.test.fail("Unexpected success for domain: " + domain); | |
27 } | |
28 req.onerror = function() { | |
29 chrome.test.assertEq(0, req.status); | |
30 chrome.test.runNextTest(); | |
31 } | |
32 } | |
33 | |
34 req.send(null); | |
35 } | |
36 | |
37 chrome.test.runTests([ | |
38 function allowedOrigin() { | |
39 doReq("http://a.com", true); | |
40 }, | |
41 function diallowedOrigin() { | |
42 doReq("http://c.com", false); | |
43 }, | |
44 function allowedSubdomain() { | |
45 doReq("http://foo.b.com", true); | |
46 }, | |
47 function noSubdomain() { | |
48 doReq("http://b.com", true); | |
49 }, | |
50 function disallowedSubdomain() { | |
51 doReq("http://foob.com", false); | |
52 }, | |
53 function disallowedSSL() { | |
54 doReq("https://a.com", false); | |
55 } | |
56 ]); | |
57 }); | |
58 | |
59 </script> | |
OLD | NEW |