2010-10-01 11:33:00 -07:00
|
|
|
let testURL = chromeRoot + "browser_select.html";
|
2009-10-14 15:43:20 -07:00
|
|
|
let new_tab = null;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Entry point (must be named "test")
|
|
|
|
function test() {
|
|
|
|
// This test is async
|
|
|
|
waitForExplicitFinish();
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2009-10-14 15:43:20 -07:00
|
|
|
// Add new tab to hold the <select> page
|
|
|
|
new_tab = Browser.addTab(testURL, true);
|
2010-08-24 01:33:43 -07:00
|
|
|
ok(new_tab, "Tab Opened");
|
2009-10-14 15:43:20 -07:00
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
// Need to wait until the page is loaded
|
|
|
|
messageManager.addMessageListener("pageshow",
|
|
|
|
function(aMessage) {
|
|
|
|
if (new_tab.browser.currentURI.spec != "about:blank") {
|
|
|
|
messageManager.removeMessageListener(aMessage.name, arguments.callee);
|
|
|
|
onPageReady();
|
|
|
|
}
|
|
|
|
});
|
2009-10-14 15:43:20 -07:00
|
|
|
}
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
function onPageReady() {
|
2009-10-14 15:43:20 -07:00
|
|
|
let combo = new_tab.browser.contentDocument.getElementById("combobox");
|
|
|
|
isnot(combo, null, "Get the select from web content");
|
|
|
|
|
2011-10-06 19:58:31 -07:00
|
|
|
new_tab.browser.contentWindow.addEventListener('mousedown', function(e) {
|
|
|
|
ok(false, e.type + ' should not have been fired');
|
|
|
|
}, true);
|
|
|
|
new_tab.browser.contentWindow.addEventListener('mouseup', function(e) {
|
|
|
|
ok(false, e.type + ' should not have been fired');
|
|
|
|
}, true);
|
|
|
|
new_tab.browser.contentWindow.addEventListener('click', function(e) {
|
|
|
|
ok(false, e.type + ' should not have been fired');
|
|
|
|
}, true);
|
|
|
|
|
2010-09-30 09:51:34 -07:00
|
|
|
let rect = browserViewToClientRect(Rect.fromRect(combo.getBoundingClientRect()));
|
2011-10-06 19:58:31 -07:00
|
|
|
ContentTouchHandler.tapDown(rect.left + 1, rect.top + 1);
|
|
|
|
ContentTouchHandler.tapSingle(rect.left + 1, rect.top + 1);
|
|
|
|
ContentTouchHandler.tapUp(rect.left + 1, rect.top + 1);
|
|
|
|
|
|
|
|
waitFor(closeSelect, function() { return document.getElementById("select-container").hidden == false; });
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeSelect() {
|
|
|
|
let selectui = document.getElementById("select-container");
|
|
|
|
is(selectui.hidden, false, "Select UI should be open");
|
|
|
|
|
|
|
|
EventUtils.sendKey("ESCAPE", window);
|
|
|
|
|
|
|
|
waitFor(tapOnMultiSelect, function() { return document.getElementById("select-container").hidden == true; });
|
|
|
|
}
|
|
|
|
|
|
|
|
function tapOnMultiSelect() {
|
|
|
|
let selectui = document.getElementById("select-container");
|
|
|
|
is(selectui.hidden, true, "Select UI should be hidden");
|
|
|
|
|
|
|
|
let option = new_tab.browser.contentDocument.getElementById("listbox-multiselect");
|
|
|
|
let rect = browserViewToClientRect(Rect.fromRect(option.getBoundingClientRect()));
|
|
|
|
ContentTouchHandler.tapDown(rect.left + 1, rect.top + 1);
|
2010-09-28 14:01:00 -07:00
|
|
|
ContentTouchHandler.tapSingle(rect.left + 1, rect.top + 1);
|
2011-10-06 19:58:31 -07:00
|
|
|
ContentTouchHandler.tapUp(rect.left + 1, rect.top + 1);
|
2010-08-24 01:33:43 -07:00
|
|
|
|
|
|
|
waitFor(onUIReady, function() { return document.getElementById("select-container").hidden == false; });
|
2009-10-14 15:43:20 -07:00
|
|
|
}
|
2010-08-24 01:33:43 -07:00
|
|
|
|
|
|
|
function onUIReady() {
|
2009-10-14 15:43:20 -07:00
|
|
|
let selectui = document.getElementById("select-container");
|
|
|
|
is(selectui.hidden, false, "Select UI should be open");
|
2011-10-06 19:58:31 -07:00
|
|
|
is(SelectHelperUI._selectedIndexes, 7, "Select UI should have the 8th option selected:" + SelectHelperUI._selectedIndexes);
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2011-10-06 19:58:31 -07:00
|
|
|
EventUtils.sendKey("ESCAPE", window);
|
2009-10-14 15:43:20 -07:00
|
|
|
|
|
|
|
// Close our tab when finished
|
|
|
|
Browser.closeTab(new_tab);
|
2010-12-07 08:45:20 -08:00
|
|
|
is(selectui.hidden, true, "Select UI should be hidden");
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2009-10-14 15:43:20 -07:00
|
|
|
// We must finialize the tests
|
|
|
|
finish();
|
|
|
|
}
|
2010-09-30 09:51:34 -07:00
|
|
|
|
|
|
|
function browserViewToClientRect(rect) {
|
|
|
|
let container = document.getElementById("browsers");
|
|
|
|
let containerBCR = container.getBoundingClientRect();
|
|
|
|
return rect.clone().translate(Math.round(containerBCR.left), Math.round(containerBCR.top));
|
|
|
|
}
|