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

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/javascript_url_permissions/test.js

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var assertEq = chrome.test.assertEq; 5 var assertEq = chrome.test.assertEq;
6 var pass = chrome.test.callbackPass; 6 var pass = chrome.test.callbackPass;
7 7
8 chrome.test.getConfig(function(config) { 8 chrome.test.getConfig(function(config) {
9 var javaScriptURL = "javascript:void(document.title='js-url-success')"; 9 var javaScriptURL = "javascript:void(document.title='js-url-success')";
10 10
11 var fixPort = function(url) { 11 var fixPort = function(url) {
12 return url.replace(/PORT/, config.testServer.port); 12 return url.replace(/PORT/, config.testServer.port);
13 }; 13 };
14 var urlA = fixPort("http://a.com:PORT/files/extensions/test_file.html"); 14 var urlA = fixPort("http://a.com:PORT/extensions/test_file.html");
15 var urlB = fixPort("http://b.com:PORT/files/extensions/test_file.html"); 15 var urlB = fixPort("http://b.com:PORT/extensions/test_file.html");
16 16
17 chrome.tabs.create({ url: urlA }, function(tab) { 17 chrome.tabs.create({ url: urlA }, function(tab) {
18 var firstTabId = tab.id; 18 var firstTabId = tab.id;
19 19
20 chrome.tabs.create({ url: urlB }, function(tab) { 20 chrome.tabs.create({ url: urlB }, function(tab) {
21 var secondTabId = tab.id; 21 var secondTabId = tab.id;
22 22
23 chrome.test.runTests([ 23 chrome.test.runTests([
24 function javaScriptURLShouldFail() { 24 function javaScriptURLShouldFail() {
25 chrome.tabs.update(firstTabId, {url: javaScriptURL}, 25 chrome.tabs.update(firstTabId, {url: javaScriptURL},
26 chrome.test.callbackFail('Cannot access contents of url ' + 26 chrome.test.callbackFail('Cannot access contents of url ' +
27 '"' + urlA + '". Extension manifest must request ' + 27 '"' + urlA + '". Extension manifest must request ' +
28 'permission to access this host.')); 28 'permission to access this host.'));
29 }, 29 },
30 30
31 function javaScriptURLShouldSucceed() { 31 function javaScriptURLShouldSucceed() {
32 chrome.tabs.update( 32 chrome.tabs.update(
33 secondTabId, 33 secondTabId,
34 {url: javaScriptURL}, 34 {url: javaScriptURL},
35 pass(function(tab) { 35 pass(function(tab) {
36 assertEq(secondTabId, tab.id); 36 assertEq(secondTabId, tab.id);
37 assertEq('js-url-success', tab.title); 37 assertEq('js-url-success', tab.title);
38 })); 38 }));
39 } 39 }
40 ]); 40 ]);
41 }); 41 });
42 }); 42 });
43 }); 43 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698