| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 chrome.tabs.executeScript(tabId, script_file, fail( | 94 chrome.tabs.executeScript(tabId, script_file, fail( |
| 95 'Cannot access contents of url "' + testFailureUrl + | 95 'Cannot access contents of a page. ' + |
| 96 '". Extension manifest must request permission to access this ' + | 96 'Extension manifest must request permission to access the ' + |
| 97 'host.')); | 97 'respective host.')); |
| 98 }); | 98 }); |
| 99 }, | 99 }, |
| 100 | 100 |
| 101 function executeJavaScriptWithNoneValueShouldFail() { | 101 function executeJavaScriptWithNoneValueShouldFail() { |
| 102 var script_file = {}; | 102 var script_file = {}; |
| 103 chrome.tabs.executeScript(tabId, script_file, fail( | 103 chrome.tabs.executeScript(tabId, script_file, fail( |
| 104 'No source code or file specified.')); | 104 'No source code or file specified.')); |
| 105 }, | 105 }, |
| 106 | 106 |
| 107 function executeJavaScriptWithTwoValuesShouldFail() { | 107 function executeJavaScriptWithTwoValuesShouldFail() { |
| 108 var script_file = {}; | 108 var script_file = {}; |
| 109 script_file.file = 'script1.js'; | 109 script_file.file = 'script1.js'; |
| 110 script_file.code = 'var test = 1;'; | 110 script_file.code = 'var test = 1;'; |
| 111 chrome.tabs.executeScript(tabId, script_file, fail( | 111 chrome.tabs.executeScript(tabId, script_file, fail( |
| 112 'Code and file should not be specified ' + | 112 'Code and file should not be specified ' + |
| 113 'at the same time in the second argument.')); | 113 'at the same time in the second argument.')); |
| 114 } | 114 } |
| 115 ]); | 115 ]); |
| 116 }); | 116 }); |
| 117 | 117 |
| 118 chrome.tabs.create({ url: testUrl }); | 118 chrome.tabs.create({ url: testUrl }); |
| 119 }); | 119 }); |
| 120 | 120 |
| OLD | NEW |