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

Unified Diff: chrome/test/data/extensions/api_test/tabs/test.js

Issue 203042: windows.create({url:}) now supports relative paths. tabs.update()/tabs.move() now return Tab. (Closed)
Patch Set: forgot page Created 11 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
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/relative.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/tabs/test.js
diff --git a/chrome/test/data/extensions/api_test/tabs/test.js b/chrome/test/data/extensions/api_test/tabs/test.js
index 0d95cf70c14bfadc513e823bd10bd656fe06d047..8c40e4ec9d3f66393a69b51e8b23c1b849365cd1 100644
--- a/chrome/test/data/extensions/api_test/tabs/test.js
+++ b/chrome/test/data/extensions/api_test/tabs/test.js
@@ -16,6 +16,11 @@ 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();
+}
+
chrome.test.runTests([
function getSelected() {
chrome.tabs.getSelected(null, pass(function(tab) {
@@ -57,7 +62,7 @@ chrome.test.runTests([
chrome.tabs.create({"windowId" : secondWindowId, "url" : "chrome://b"},
pass());
}));
- }));
+ }));
},
function getAllFirstWindow() {
@@ -97,8 +102,9 @@ chrome.test.runTests([
chrome.tabs.get(testTabId, pass(function(tab) {
assertEq("chrome://a/", tab.url);
// Update url.
- chrome.tabs.update(testTabId, {"url": "chrome://c"},
- pass(function(){
+ chrome.tabs.update(testTabId, {"url": "chrome://c/"},
+ pass(function(tab){
+ chrome.test.assertEq("chrome://c/", tab.url);
// Check url.
chrome.tabs.get(testTabId, pass(function(tab) {
assertEq("chrome://c/", tab.url);
@@ -113,15 +119,17 @@ chrome.test.runTests([
assertEq(true, tabs[2].selected);
// Select tab[1].
chrome.tabs.update(tabs[1].id, {selected: true},
- pass(function(){
+ pass(function(tab1){
// Check update of tab[1].
+ chrome.test.assertEq(true, tab1.selected);
chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) {
assertEq(true, tabs[1].selected);
assertEq(false, tabs[2].selected);
// Select tab[2].
chrome.tabs.update(tabs[2].id, {selected: true},
- pass(function(){
+ pass(function(tab2){
// Check update of tab[2].
+ chrome.test.assertEq(true, tab2.selected);
chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) {
assertEq(false, tabs[1].selected);
assertEq(true, tabs[2].selected);
@@ -183,15 +191,19 @@ chrome.test.runTests([
// Window2: b,(newtab),d
function moveTabs() {
chrome.tabs.move(moveTabIds['b'], {"windowId": moveWindow2, "index": 0},
- pass(function() {
+ pass(function(tabB) {
+ chrome.test.assertEq(0, tabB.index);
chrome.tabs.move(moveTabIds['e'], {"index": 2},
- pass(function() {
+ pass(function(tabE) {
+ chrome.test.assertEq(2, tabE.index);
chrome.tabs.move(moveTabIds['d'], {"windowId": moveWindow2,
- "index": 2}, pass(function() {}));
+ "index": 2}, pass(function(tabD) {
+ chrome.test.assertEq(2, tabD.index);
+ }));
}));
}));
},
-
+
// Check that the tab/window state is what we expect after doing moves.
function moveTabsCheck() {
chrome.tabs.getAllInWindow(moveWindow1, pass(function(tabs) {
@@ -309,6 +321,43 @@ chrome.test.runTests([
});
chrome.tabs.remove(moveTabIds['c'], pass());
+ },
+
+ function setupRelativeUrlTests() {
+ chrome.windows.create({}, pass(function(win) {
+ assertTrue(win.id > 0);
+ firstWindowId = win.id;
+
+ chrome.windows.getAll({}, pass(function(windows) {
+ for (var i = 0; i < windows.length; i++) {
+ if (windows[i].id != firstWindowId) {
+ chrome.windows.remove(windows[i].id, pass());
+ }
+ }
+ }));
+ }));
+ },
+
+ // The subsequent three tests all load relative.html, which calls
+ // this page's relativePageLoad(), which ends the test.
+ function relativeUrlTabsCreate() {
+ chrome.tabs.create({windowId: firstWindowId, url: 'relative.html'},
+ pass(function(tab){
+ testTabId = tab.id;
+ }
+ ));
+ },
+
+ function relativeUrlTabsUpdate() {
+ chrome.tabs.update(testTabId, {url: "chrome://a/"}, function(tab) {
+ chrome.test.assertEq("chrome://a/", tab.url);
+ chrome.tabs.update(tab.id, {url: "relative.html"}, function(tab) {
+ });
+ });
+ },
+
+ function relativeUrlWindowsCreate() {
+ chrome.windows.create({url: "relative.html"});
}
// TODO(asargent) We still need to add tests for the following:
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/relative.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698