summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 20:16:41 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 20:16:41 +0000
commitd328413b739ed1150369743a64cacfb167086a32 (patch)
tree3c4c18ff0d0256bc3372420bf3c7a18ab0d64088 /chrome/test
parentad6d2c4304320a300009682901199278fabd3148 (diff)
downloadchromium_src-d328413b739ed1150369743a64cacfb167086a32.zip
chromium_src-d328413b739ed1150369743a64cacfb167086a32.tar.gz
chromium_src-d328413b739ed1150369743a64cacfb167086a32.tar.bz2
Address ExtensionApiTest.Tabs flakiness
This addresses two problems. (1) relativeUrlTabsUpdate could fail because it was depending on testTabId getting set from relativeUrlTabsCreate, which may have happened out of order. I have refactored the callback blocking so additional blocks can be created with chrome.test.callbackAdded(). (2) tabs.update({url:}) is still failing intermitantly. This changes addeds valid html files in the extension which can be navitation targets (previously, non-existent urls had been used), in the hopes that the random failures had to do with load errors. BUG=20828 Review URL: http://codereview.chromium.org/195090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rwxr-xr-xchrome/test/data/extensions/api_test/tabs/a.html5
-rwxr-xr-xchrome/test/data/extensions/api_test/tabs/b.html5
-rwxr-xr-xchrome/test/data/extensions/api_test/tabs/c.html5
-rwxr-xr-xchrome/test/data/extensions/api_test/tabs/d.html5
-rwxr-xr-xchrome/test/data/extensions/api_test/tabs/e.html5
-rwxr-xr-xchrome/test/data/extensions/api_test/tabs/f.html5
-rw-r--r--chrome/test/data/extensions/api_test/tabs/test.js74
7 files changed, 71 insertions, 33 deletions
diff --git a/chrome/test/data/extensions/api_test/tabs/a.html b/chrome/test/data/extensions/api_test/tabs/a.html
new file mode 100755
index 0000000..dcd442e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/a.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>A</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/b.html b/chrome/test/data/extensions/api_test/tabs/b.html
new file mode 100755
index 0000000..7bff50a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/b.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>B</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/c.html b/chrome/test/data/extensions/api_test/tabs/c.html
new file mode 100755
index 0000000..ccaad19
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/c.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>C</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/d.html b/chrome/test/data/extensions/api_test/tabs/d.html
new file mode 100755
index 0000000..6d5df4a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/d.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>D</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/e.html b/chrome/test/data/extensions/api_test/tabs/e.html
new file mode 100755
index 0000000..8f6e3c1
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/e.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>E</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/f.html b/chrome/test/data/extensions/api_test/tabs/f.html
new file mode 100755
index 0000000..0b00692
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/f.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>F</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/test.js b/chrome/test/data/extensions/api_test/tabs/test.js
index 0f6cc5b..867a34c 100644
--- a/chrome/test/data/extensions/api_test/tabs/test.js
+++ b/chrome/test/data/extensions/api_test/tabs/test.js
@@ -16,9 +16,8 @@ var pass = chrome.test.callbackPass;
var assertEq = chrome.test.assertEq;
var assertTrue = chrome.test.assertTrue;
-// Called by relative.html during onload.
-function relativePageLoaded() {
- chrome.test.succeed();
+function pageUrl(letter) {
+ return chrome.extension.getURL(letter + ".html");
}
chrome.test.runTests([
@@ -56,10 +55,10 @@ chrome.test.runTests([
assertTrue(win.id > 0);
secondWindowId = win.id;
// Create first window.
- chrome.tabs.create({"windowId" : firstWindowId, "url" : "chrome://a"},
+ chrome.tabs.create({"windowId" : firstWindowId, "url" : pageUrl("a")},
pass(function() {
// Create second window.
- chrome.tabs.create({"windowId" : secondWindowId, "url" : "chrome://b"},
+ chrome.tabs.create({"windowId" : secondWindowId, "url" :pageUrl("b")},
pass());
}));
}));
@@ -80,7 +79,7 @@ chrome.test.runTests([
}
assertEq("about:blank", tabs[0].url);
assertEq("chrome://newtab/", tabs[1].url);
- assertEq("chrome://a/", tabs[2].url);
+ assertEq(pageUrl("a"), tabs[2].url);
testTabId = tabs[2].id;
}));
},
@@ -94,20 +93,20 @@ chrome.test.runTests([
assertEq(i, tabs[i].index);
}
assertEq("chrome://newtab/", tabs[0].url);
- assertEq("chrome://b/", tabs[1].url);
+ assertEq(pageUrl("b"), tabs[1].url);
}));
},
function updateUrl() {
chrome.tabs.get(testTabId, pass(function(tab) {
- assertEq("chrome://a/", tab.url);
+ assertEq(pageUrl("a"), tab.url);
// Update url.
- chrome.tabs.update(testTabId, {"url": "chrome://c/"},
+ chrome.tabs.update(testTabId, {"url": pageUrl("c")},
pass(function(tab){
- chrome.test.assertEq("chrome://c/", tab.url);
+ chrome.test.assertEq(pageUrl("c"), tab.url);
// Check url.
chrome.tabs.get(testTabId, pass(function(tab) {
- assertEq("chrome://c/", tab.url);
+ assertEq(pageUrl("c"), tab.url);
}));
}));
}));
@@ -158,9 +157,9 @@ chrome.test.runTests([
var letters = ['a', 'b', 'c', 'd', 'e'];
for (var i in letters) {
chrome.tabs.create({"windowId": moveWindow1,
- "url": "chrome://" + letters[i]},
+ "url": pageUrl(letters[i])},
pass(function(tab) {
- var letter = tab.url[tab.url.length-2];
+ var letter = tab.url[tab.url.length-6];
moveTabIds[letter] = tab.id;
// Assert on last callback that tabs were added in the order we created
@@ -169,11 +168,11 @@ chrome.test.runTests([
chrome.tabs.getAllInWindow(moveWindow1, pass(function(tabs) {
assertEq(6, tabs.length);
assertEq("chrome://newtab/", tabs[0].url);
- assertEq("chrome://a/", tabs[1].url);
- assertEq("chrome://b/", tabs[2].url);
- assertEq("chrome://c/", tabs[3].url);
- assertEq("chrome://d/", tabs[4].url);
- assertEq("chrome://e/", tabs[5].url);
+ assertEq(pageUrl("a"), tabs[1].url);
+ assertEq(pageUrl("b"), tabs[2].url);
+ assertEq(pageUrl("c"), tabs[3].url);
+ assertEq(pageUrl("d"), tabs[4].url);
+ assertEq(pageUrl("e"), tabs[5].url);
}));
}
}));
@@ -209,15 +208,15 @@ chrome.test.runTests([
chrome.tabs.getAllInWindow(moveWindow1, pass(function(tabs) {
assertEq(4, tabs.length);
assertEq("chrome://newtab/", tabs[0].url);
- assertEq("chrome://a/", tabs[1].url);
- assertEq("chrome://e/", tabs[2].url);
- assertEq("chrome://c/", tabs[3].url);
+ assertEq(pageUrl("a"), tabs[1].url);
+ assertEq(pageUrl("e"), tabs[2].url);
+ assertEq(pageUrl("c"), tabs[3].url);
chrome.tabs.getAllInWindow(moveWindow2, pass(function(tabs) {
assertEq(3, tabs.length);
- assertEq("chrome://b/", tabs[0].url);
+ assertEq(pageUrl("b"), tabs[0].url);
assertEq("chrome://newtab/", tabs[1].url);
- assertEq("chrome://d/", tabs[2].url);
+ assertEq(pageUrl("d"), tabs[2].url);
}));
}));
},
@@ -227,7 +226,7 @@ chrome.test.runTests([
chrome.tabs.getAllInWindow(moveWindow2,
pass(function(tabs) {
assertEq(2, tabs.length);
- assertEq("chrome://b/", tabs[0].url);
+ assertEq(pageUrl("b"), tabs[0].url);
assertEq("chrome://newtab/", tabs[1].url);
}));
}));
@@ -276,23 +275,23 @@ chrome.test.runTests([
function onCreated() {
chrome.test.listenOnce(chrome.tabs.onCreated, function(tab) {
- assertEq("chrome://f/", tab.url);
+ assertEq(pageUrl("f"), tab.url);
});
- chrome.tabs.create({"windowId": moveWindow1, "url": "chrome://f",
+ chrome.tabs.create({"windowId": moveWindow1, "url": pageUrl("f"),
"selected": true}, pass(function(tab) {}));
},
function onUpdated() {
- var listener = chrome.test.listenForever(chrome.tabs.onUpdated,
+ var onUpdatedCompleted = chrome.test.listenForever(chrome.tabs.onUpdated,
function(tabid, info) {
if (tabid == moveTabIds['a'] && info.status == "complete") {
- listener.doneListening();
+ onUpdatedCompleted();
}
}
);
- chrome.tabs.update(moveTabIds['a'], {"url": "chrome://aa"},
+ chrome.tabs.update(moveTabIds['a'], {"url": pageUrl("f")},
pass());
},
@@ -338,25 +337,34 @@ chrome.test.runTests([
}));
},
- // The subsequent three tests all load relative.html, which calls
- // this page's relativePageLoad(), which ends the test.
function relativeUrlTabsCreate() {
+ // Will be called from relative.html
+ window.relativePageLoaded = chrome.test.callbackAdded();
+ var createCompleted = chrome.test.callbackAdded();
+
chrome.tabs.create({windowId: firstWindowId, url: 'relative.html'},
function(tab){
testTabId = tab.id;
+ createCompleted();
}
);
},
function relativeUrlTabsUpdate() {
- chrome.tabs.update(testTabId, {url: "chrome://a/"}, function(tab) {
- chrome.test.assertEq("chrome://a/", tab.url);
+ // Will be called from relative.html
+ window.relativePageLoaded = chrome.test.callbackAdded();
+
+ chrome.tabs.update(testTabId, {url: pageUrl("a")}, function(tab) {
+ chrome.test.assertEq(pageUrl("a"), tab.url);
chrome.tabs.update(tab.id, {url: "relative.html"}, function(tab) {
});
});
},
function relativeUrlWindowsCreate() {
+ // Will be called from relative.html
+ window.relativePageLoaded = chrome.test.callbackAdded();
+
chrome.windows.create({url: "relative.html"});
}