Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: chrome/test/data/extensions/api_test/cross_origin_xhr/background_page/test.js

Issue 8725019: Move another bunch of extension API tests to manifest_version 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 chrome.test.getConfig(function(config) {
6
7 function doReq(domain, expectSuccess) {
8 var req = new XMLHttpRequest();
9 var url = domain + ":PORT/files/extensions/test_file.txt";
10 url = url.replace(/PORT/, config.testServer.port);
11
12 chrome.test.log("Requesting url: " + url);
13 req.open("GET", url, true);
14
15
16 if (expectSuccess) {
17 req.onload = function() {
18 chrome.test.assertEq(200, req.status);
19 chrome.test.assertEq("Hello!", req.responseText);
20 chrome.test.runNextTest();
21 }
22 req.onerror = function() {
23 chrome.test.log("status: " + req.status);
24 chrome.test.log("text: " + req.responseText);
25 chrome.test.fail("Unexpected error for domain: " + domain);
26 }
27 } else {
28 req.onload = function() {
29 chrome.test.fail("Unexpected success for domain: " + domain);
30 }
31 req.onerror = function() {
32 chrome.test.assertEq(0, req.status);
33 chrome.test.runNextTest();
34 }
35 }
36
37 req.send(null);
38 }
39
40 chrome.test.runTests([
41 function allowedOrigin() {
42 doReq("http://a.com", true);
43 },
44 function diallowedOrigin() {
45 doReq("http://c.com", false);
46 },
47 function allowedSubdomain() {
48 doReq("http://foo.b.com", true);
49 },
50 function noSubdomain() {
51 doReq("http://b.com", true);
52 },
53 function disallowedSubdomain() {
54 doReq("http://foob.com", false);
55 },
56 function disallowedSSL() {
57 doReq("https://a.com", false);
58 }
59 ]);
60 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698