Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2009)

Unified Diff: chrome/test/data/extensions/api_test/executescript/in_frame/test.js

Issue 2300453002: [Extensions] Begin making Extension port initialization asynchronous (Closed)
Patch Set: lazyboys Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
});
}
]);

Powered by Google App Engine
This is Rietveld 408576698