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
3 // found in the LICENSE file.
5 var assertEq = chrome.test.assertEq;
6 var pass = chrome.test.callbackPass;
8 chrome.test.getConfig(function(config) {
9 var javaScriptURL = "javascript:void(document.title='js-url-success')";
11 var fixPort = function(url) {
12 return url.replace(/PORT/, config.testServer.port);
14 var urlA = fixPort("http://a.com:PORT/extensions/test_file.html");
15 var urlB = fixPort("http://b.com:PORT/extensions/test_file.html");
17 chrome.tabs.create({ url: urlA }, function(tab) {
18 var firstTabId = tab.id;
20 chrome.tabs.create({ url: urlB }, function(tab) {
21 var secondTabId = tab.id;
23 chrome.test.runTests([
24 function javaScriptURLShouldFail() {
25 chrome.tabs.update(firstTabId, {url: javaScriptURL},
26 chrome.test.callbackFail('Cannot access contents of url ' +
27 '"' + urlA + '". Extension manifest must request ' +
28 'permission to access this host.'));
31 function javaScriptURLShouldSucceed() {
36 assertEq(secondTabId, tab.id);
37 assertEq('js-url-success', tab.title);