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

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: Nasko's 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..d4f1eabdadfe3940e92c756e521005bfdaf7335f 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,24 @@ 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++;
+ assertTrue(counter <= 5);
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 +49,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 +69,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