Index: chrome/test/data/extensions/api_test/executescript/in_frame/test.js |
diff --git a/chrome/test/data/extensions/api_test/executescript/in_frame/test.js b/chrome/test/data/extensions/api_test/executescript/in_frame/test.js |
index 1c3ca0bd364067e606f2816b0973b58af97dce59..6f9239b6ef2715dbc510b0cbf0c1a62d3d65d35f 100644 |
--- a/chrome/test/data/extensions/api_test/executescript/in_frame/test.js |
+++ b/chrome/test/data/extensions/api_test/executescript/in_frame/test.js |
@@ -23,18 +23,23 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
script_file.allFrames = true; |
var counter = 0; |
var totalTitles = ''; |
+ var done = pass(); |
+ function verifyAndFinish() { |
+ assertEq(counter, 5); |
+ assertEq(totalTitles, 'frametest0test1test2test3'); |
+ chrome.runtime.onConnect.removeListener(eventListener); |
+ done(); |
+ } |
function eventListener(port) { |
port.onMessage.addListener(function(data) { |
counter++; |
lazyboy
2016/09/08 21:59:16
asertTrue(counter<=5), i.e. catch if it gets calle
Devlin
2016/09/09 16:10:34
Done.
|
totalTitles += data.message; |
+ if (counter == 5) |
+ verifyAndFinish(); |
}); |
}; |
chrome.runtime.onConnect.addListener(eventListener); |
- chrome.tabs.executeScript(tabId, script_file, pass(function() { |
- assertEq(counter, 5); |
- assertEq(totalTitles, 'frametest0test1test2test3'); |
- chrome.runtime.onConnect.removeListener(eventListener); |
- })); |
+ chrome.tabs.executeScript(tabId, script_file); |
}, |
function insertCSSTextInAllFramesShouldSucceed() { |
@@ -43,10 +48,19 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
css_file.allFrames = true; |
var newStyle = ''; |
var counter = 0; |
+ var done = pass(); |
+ function verifyAndFinish() { |
+ assertEq(newStyle, 'nonenonenonenone'); |
+ assertEq(counter, 4); |
+ chrome.runtime.onConnect.removeListener(eventListener); |
+ done(); |
+ } |
function eventListener(port) { |
port.onMessage.addListener(function(data) { |
counter++; |
newStyle += data.message; |
+ if (counter == 4) |
+ verifyAndFinish(); |
}); |
}; |
chrome.runtime.onConnect.addListener(eventListener); |
@@ -54,12 +68,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
var script_file = {}; |
script_file.file = 'script.js'; |
script_file.allFrames = true; |
- chrome.tabs.executeScript(tabId, script_file, |
- pass(function() { |
- assertEq(newStyle, 'nonenonenonenone'); |
- assertEq(counter, 4); |
- chrome.runtime.onConnect.removeListener(eventListener); |
- })); |
+ chrome.tabs.executeScript(tabId, script_file); |
}); |
} |
]); |