Skip to content

Commit

Permalink
added additional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
canuckistani committed Dec 28, 2012
1 parent ae0d050 commit 2e692a0
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/tabs/test-fennec-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,3 +620,44 @@ exports.testActiveTab_getter_alt = function(test) {
}
});
};

exports.testUniqueTabIds = function(test) {
test.waitUntilDone();
var tabs = require('sdk/tabs');
var tabIds = {};
var steps = [
function (index) {
tabs.open({
url: "data:text/html;charset=utf-8,foo",
onOpen: function(tab) {
tabIds['tab1'] = tab.id;
next(index);
}
});
},
function (index) {
tabs.open({
url: "data:text/html;charset=utf-8,bar",
onOpen: function(tab) {
tabIds['tab2'] = tab.id;
next(index);
}
});
},
function (index) {
test.assertNotEqual(tabIds.tab1, tabIds.tab2, "Tab ids should be unique.");
test.done();
}
];

function next(index) {
if (index === steps.length) {
return;
}
let fn = steps[index];
index++;
fn(index);
}

next(0);
}
47 changes: 47 additions & 0 deletions test/tabs/test-firefox-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,53 @@ exports['test ready event on new window tab'] = function(test) {

let window = openBrowserWindow(function(){}, uri);
};

exports['test unique tab ids'] = function(test) {
test.waitUntilDone();

var windows = require('windows').browserWindows,
tabIds = {}, win1, win2;

let steps = [
function (index) {
win1 = windows.open({
url: "data:text/html;charset=utf-8,foo",
onOpen: function(window) {
tabIds['tab1'] = window.tabs.activeTab.id;
next(index);
}
});
},
function (index) {
win2 = windows.open({
url: "data:text/html;charset=utf-8,foo",
onOpen: function(window) {
tabIds['tab2'] = window.tabs.activeTab.id;
next(index);
}
});
},
function (index) {
test.assertNotEqual(tabIds.tab1, tabIds.tab2, "Tab ids should be unique.");
win1.close();
win2.close();
test.done();
}
];

function next(index) {
if (index === steps.length) {
return;
}
let fn = steps[index];
index++
fn(index);
}

// run!
next(0);
}

/******************* helpers *********************/

// Helper for getting the active window
Expand Down

0 comments on commit 2e692a0

Please sign in to comment.