OLD | NEW |
---|---|
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 relativePath = | 5 var relativePath = |
6 '/files/extensions/api_test/executescript/callback/test.html'; | 6 '/files/extensions/api_test/executescript/callback/test.html'; |
7 var testUrl = 'http://b.com:PORT' + relativePath; | 7 var testUrl = 'http://b.com:PORT' + relativePath; |
8 | 8 |
9 chrome.test.getConfig(function(config) { | 9 chrome.test.getConfig(function(config) { |
10 testUrl = testUrl.replace(/PORT/, config.testServer.port); | 10 testUrl = testUrl.replace(/PORT/, config.testServer.port); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 var scriptDetails = {code: 'var obj = {"id": "foo", "bar": 9}; obj'}; | 81 var scriptDetails = {code: 'var obj = {"id": "foo", "bar": 9}; obj'}; |
82 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { | 82 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { |
83 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { | 83 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { |
84 chrome.test.assertEq({"id": "foo", "bar": 9}, scriptVal[0]); | 84 chrome.test.assertEq({"id": "foo", "bar": 9}, scriptVal[0]); |
85 })); | 85 })); |
86 }); | 86 }); |
87 }, | 87 }, |
88 | 88 |
89 // Non-pure ojbects (like DOM nodes) will get converted as best they can. | 89 // Non-pure ojbects (like DOM nodes) will get converted as best they can. |
90 function executeCallbackDOMObjShouldSucceed() { | 90 function executeCallbackDOMObjShouldSucceed() { |
91 var scriptDetails = {} | 91 var scriptDetails = {}; |
92 scriptDetails.code = 'var a = document.getElementById("testDiv"); a'; | 92 scriptDetails.code = 'var a = document.getElementById("testDiv"); a;'; |
93 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { | 93 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { |
94 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { | 94 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { |
95 // Test passes as long as the DOM node was converted in some form | 95 // Test passes as long as the DOM node was converted in some form |
96 // and is not null | 96 // and is not null |
97 chrome.test.assertTrue(scriptVal[0] != null); | 97 chrome.test.assertTrue(scriptVal[0] != null); |
98 })); | 98 })); |
99 }); | 99 }); |
100 }, | 100 }, |
101 | 101 |
102 // All non-integer properties are droped. | 102 // All non-integer properties are droped. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 | 141 |
142 function executeCallbackWindowShouldSucceed() { | 142 function executeCallbackWindowShouldSucceed() { |
143 var scriptDetails = {code: 'window;'}; | 143 var scriptDetails = {code: 'window;'}; |
144 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { | 144 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { |
145 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { | 145 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { |
146 // Test passes as long as the window was converted in some form and | 146 // Test passes as long as the window was converted in some form and |
147 // is not null | 147 // is not null |
148 chrome.test.assertFalse(null == scriptVal[0]); | 148 chrome.test.assertFalse(null == scriptVal[0]); |
149 })); | 149 })); |
150 }); | 150 }); |
151 }, | |
152 | |
153 function executeCallbackInputShouldSucceed() { | |
154 var scriptDetails = {}; | |
155 scriptDetails.code = 'var a = document.getElementById("testInput"); a;'; | |
156 chrome.tabs.executeScript(tabId, scriptDetails, function(scriptVal) { | |
157 chrome.tabs.get(tabId, chrome.test.callbackPass(function(tab) { | |
158 // Test passes as long as the input element was converted in some | |
159 // form and is not null | |
160 chrome.test.assertTrue(scriptVal[0] != null); | |
not at google - send to devlin
2012/08/02 18:59:41
drive-by: should this be a V8UnitTest?
eaugusti
2012/08/02 19:44:53
Yes, it should be. It is just hard because it is a
| |
161 })); | |
162 }); | |
151 } | 163 } |
152 ]); | 164 ]); |
153 }); | 165 }); |
154 chrome.tabs.create({ url: testUrl }); | 166 chrome.tabs.create({ url: testUrl }); |
155 | 167 |
156 }); | 168 }); |
OLD | NEW |