Commit 0d9c7742 authored by ahest's avatar ahest Committed by Commit bot

Fix race condition in ExtensionApiTest.Messaging.

chrome.tabs.onUpdated may fire when the listener is not set up yet.

BUG=

Review URL: https://codereview.chromium.org/537953002

Cr-Commit-Position: refs/heads/master@{#293637}
parent cede2dd6
...@@ -28,18 +28,20 @@ chrome.test.getConfig(function(config) { ...@@ -28,18 +28,20 @@ chrome.test.getConfig(function(config) {
chrome.test.runTests([ chrome.test.runTests([
function setupTestTab() { function setupTestTab() {
chrome.test.log("Creating tab..."); chrome.test.log("Creating tab...");
var newTab = null;
var doneListening = listenForever(chrome.tabs.onUpdated,
function(_, info, tab) {
if (newTab && tab.id == newTab.id && info.status == 'complete') {
chrome.test.log("Created tab: " + tab.url);
testTab = tab;
doneListening();
}
});
chrome.tabs.create({ chrome.tabs.create({
url: "http://localhost:PORT/extensions/test_file.html" url: "http://localhost:PORT/extensions/test_file.html"
.replace(/PORT/, config.testServer.port) .replace(/PORT/, config.testServer.port)
}, function(newTab) { }, function(tab) {
var doneListening = listenForever(chrome.tabs.onUpdated, newTab = tab;
function(_, info, tab) {
if (tab.id == newTab.id && info.status == 'complete') {
chrome.test.log("Created tab: " + tab.url);
testTab = tab;
doneListening();
}
});
}); });
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment