| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 pass = chrome.test.callbackPass; | 5 var pass = chrome.test.callbackPass; |
| 6 var fail = chrome.test.callbackFail; | 6 var fail = chrome.test.callbackFail; |
| 7 var assertEq = chrome.test.assertEq; | 7 var assertEq = chrome.test.assertEq; |
| 8 var assertTrue = chrome.test.assertTrue; | 8 var assertTrue = chrome.test.assertTrue; |
| 9 var relativePath = | 9 var relativePath = |
| 10 '/extensions/api_test/executescript/basic/test_executescript.html'; | 10 '/extensions/api_test/executescript/basic/test_executescript.html'; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 assertEq('0', tab.title); | 84 assertEq('0', tab.title); |
| 85 })); | 85 })); |
| 86 }); | 86 }); |
| 87 }); | 87 }); |
| 88 }, | 88 }, |
| 89 | 89 |
| 90 function executeJavaScriptCodeShouldFail() { | 90 function executeJavaScriptCodeShouldFail() { |
| 91 chrome.tabs.update(tabId, { url: testFailureUrl }, function() { | 91 chrome.tabs.update(tabId, { url: testFailureUrl }, function() { |
| 92 var script_file = {}; | 92 var script_file = {}; |
| 93 script_file.code = "document.title = 'executeScript';"; | 93 script_file.code = "document.title = 'executeScript';"; |
| 94 // The error message should contain the URL of the site for which it |
| 95 // failed because the extension has the tabs permission. |
| 94 chrome.tabs.executeScript(tabId, script_file, fail( | 96 chrome.tabs.executeScript(tabId, script_file, fail( |
| 95 'Cannot access contents of url "' + testFailureUrl + | 97 'Cannot access contents of url "' + testFailureUrl + |
| 96 '". Extension manifest must request permission to access this ' + | 98 '". Extension manifest must request permission to access this ' + |
| 97 'host.')); | 99 'host.')); |
| 98 }); | 100 }); |
| 99 }, | 101 }, |
| 100 | 102 |
| 101 function executeJavaScriptWithNoneValueShouldFail() { | 103 function executeJavaScriptWithNoneValueShouldFail() { |
| 102 var script_file = {}; | 104 var script_file = {}; |
| 103 chrome.tabs.executeScript(tabId, script_file, fail( | 105 chrome.tabs.executeScript(tabId, script_file, fail( |
| 104 'No source code or file specified.')); | 106 'No source code or file specified.')); |
| 105 }, | 107 }, |
| 106 | 108 |
| 107 function executeJavaScriptWithTwoValuesShouldFail() { | 109 function executeJavaScriptWithTwoValuesShouldFail() { |
| 108 var script_file = {}; | 110 var script_file = {}; |
| 109 script_file.file = 'script1.js'; | 111 script_file.file = 'script1.js'; |
| 110 script_file.code = 'var test = 1;'; | 112 script_file.code = 'var test = 1;'; |
| 111 chrome.tabs.executeScript(tabId, script_file, fail( | 113 chrome.tabs.executeScript(tabId, script_file, fail( |
| 112 'Code and file should not be specified ' + | 114 'Code and file should not be specified ' + |
| 113 'at the same time in the second argument.')); | 115 'at the same time in the second argument.')); |
| 114 } | 116 } |
| 115 ]); | 117 ]); |
| 116 }); | 118 }); |
| 117 | 119 |
| 118 chrome.tabs.create({ url: testUrl }); | 120 chrome.tabs.create({ url: testUrl }); |
| 119 }); | 121 }); |
| 120 | 122 |
| OLD | NEW |