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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 function executeCallbackObjShouldSucceed() { | 80 function executeCallbackObjShouldSucceed() { |
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 object (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 }); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // form and is not null | 159 // form and is not null |
160 chrome.test.assertTrue(scriptVal[0] != null); | 160 chrome.test.assertTrue(scriptVal[0] != null); |
161 })); | 161 })); |
162 }); | 162 }); |
163 } | 163 } |
164 ]); | 164 ]); |
165 }); | 165 }); |
166 chrome.tabs.create({ url: testUrl }); | 166 chrome.tabs.create({ url: testUrl }); |
167 | 167 |
168 }); | 168 }); |
OLD | NEW |