2010-06-11 12:17:14 -07:00
|
|
|
// Bug 489158 - --browser-chrome Mochitests on Fennec [preferences]
|
|
|
|
|
|
|
|
|
|
|
|
var gTests = [];
|
|
|
|
var gCurrentTest = null;
|
|
|
|
var initialDragOffset = null;
|
|
|
|
var finalDragOffset = null;
|
|
|
|
let x = {};
|
|
|
|
let y = {};
|
|
|
|
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
function dragElement(element, x1, y1, x2, y2) {
|
2010-06-11 12:17:14 -07:00
|
|
|
EventUtils.synthesizeMouse(element, x1, y1, { type: "mousedown" });
|
|
|
|
EventUtils.synthesizeMouse(element, x2, y2, { type: "mousemove" });
|
|
|
|
EventUtils.synthesizeMouse(element, x2, y2, { type: "mouseup" });
|
|
|
|
}
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
function doubleClick(element, x, y) {
|
2010-06-11 12:17:14 -07:00
|
|
|
EventUtils.synthesizeMouse(element, x, y, {});
|
|
|
|
EventUtils.synthesizeMouse(element, x, y, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
// The "runNextTest" approach is async, so we need to call "waitForExplicitFinish()"
|
|
|
|
// We call "finish()" when the tests are finished
|
|
|
|
waitForExplicitFinish();
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2010-06-11 12:17:14 -07:00
|
|
|
// Start the tests
|
|
|
|
runNextTest();
|
|
|
|
}
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2010-06-11 12:17:14 -07:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Iterating tests by shifting test out one by one as runNextTest is called.
|
|
|
|
function runNextTest() {
|
|
|
|
// Run the next test until all tests completed
|
|
|
|
if (gTests.length > 0) {
|
|
|
|
gCurrentTest = gTests.shift();
|
|
|
|
info(gCurrentTest.desc);
|
|
|
|
gCurrentTest.run();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Cleanup. All tests are completed at this point
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2010-06-11 12:17:14 -07:00
|
|
|
// ------------------Verifying panning of preferences list----------------------
|
|
|
|
gTests.push({
|
|
|
|
desc: "Test basic panning of Preferences",
|
2010-08-24 01:33:43 -07:00
|
|
|
_currentTab: null,
|
|
|
|
_contentScrollbox: document.getElementById("controls-scrollbox").boxObject.QueryInterface(Ci.nsIScrollBoxObject),
|
|
|
|
_prefsScrollbox: document.getAnonymousElementByAttribute(document.getElementById("prefs-list"), "anonid", "main-box")
|
|
|
|
.boxObject.QueryInterface(Ci.nsIScrollBoxObject),
|
|
|
|
|
|
|
|
run: function() {
|
|
|
|
this._currentTab = Browser.addTab("about:blank", true);
|
|
|
|
|
|
|
|
messageManager.addMessageListener("pageshow",
|
|
|
|
function(aMessage) {
|
|
|
|
messageManager.removeMessageListener(aMessage.name, arguments.callee);
|
2010-06-11 12:17:14 -07:00
|
|
|
gCurrentTest.onPageLoad();
|
2010-08-24 01:33:43 -07:00
|
|
|
});
|
2010-06-11 12:17:14 -07:00
|
|
|
},
|
2010-08-24 01:33:43 -07:00
|
|
|
|
|
|
|
onPageLoad: function() {
|
2010-06-11 12:17:14 -07:00
|
|
|
// check whether the right sidebar is invisible
|
|
|
|
let controls = document.getElementById("controls-scrollbox");
|
|
|
|
|
|
|
|
// Assign offsets while panning
|
2010-06-30 07:39:14 -07:00
|
|
|
initialDragOffset = document.getElementById("tabs-container").getBoundingClientRect().width;
|
2010-08-24 01:33:43 -07:00
|
|
|
finalDragOffset = initialDragOffset + document.getElementById("browser-controls").getBoundingClientRect().width;
|
2010-06-11 12:17:14 -07:00
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
gCurrentTest._contentScrollbox.getPosition(x, y);
|
|
|
|
ok((x.value == initialDragOffset && y.value == 0), "The right sidebar must be invisible",
|
|
|
|
"Got " + x.value + " " + y.value + ", expected " + initialDragOffset + ",0");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
/* XXX For some reasons reavealing the sidebars this way let the test hang, we need to find why and fix that
|
2010-06-11 12:17:14 -07:00
|
|
|
// Reveal right sidebar
|
|
|
|
let w = controls.clientWidth;
|
|
|
|
let h = controls.clientHeight;
|
2010-08-24 01:33:43 -07:00
|
|
|
dragElement(controls, w / 2, h / 2, w / 4, h / 2);
|
|
|
|
*/
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// check whether the right sidebar has appeared
|
|
|
|
gCurrentTest._contentScrollbox.getPosition(x,y);
|
2010-08-24 01:33:43 -07:00
|
|
|
todo((x.value == finalDragOffset && y.value == 0), "The right sidebar must be visible",
|
|
|
|
"Got " + x.value + " " + y.value + ", expected " + finalDragOffset + ",0");
|
|
|
|
|
2010-06-11 12:17:14 -07:00
|
|
|
// check to see if the preference open button is visible and not depressed
|
|
|
|
var prefsOpen = document.getElementById("tool-panel-open");
|
|
|
|
is(prefsOpen.hidden, false, "Preferences open button must be visible");
|
|
|
|
is(prefsOpen.checked, false, "Preferences open button must not be depressed");
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
// check if preferences pane is invisble
|
2010-06-30 06:57:48 -07:00
|
|
|
is(BrowserUI.isPanelVisible(), false, "Preferences panel is invisble");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// click on the prefs button to go the preferences pane
|
|
|
|
var prefsClick = document.getElementById("tool-panel-open");
|
|
|
|
prefsClick.click();
|
2010-06-30 06:57:48 -07:00
|
|
|
waitFor(gCurrentTest.onPrefsView, BrowserUI.isPanelVisible);
|
2010-06-11 12:17:14 -07:00
|
|
|
},
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
onPrefsView: function() {
|
2010-06-11 12:17:14 -07:00
|
|
|
let prefsList = document.getElementById("prefs-list");
|
|
|
|
let w = prefsList.clientWidth;
|
|
|
|
let h = prefsList.clientHeight;
|
|
|
|
|
|
|
|
//check whether the preferences panel is visible
|
2010-06-30 06:57:48 -07:00
|
|
|
ok(BrowserUI.isPanelVisible(), "Preferences panel must now be visble");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// Check if preferences container is visible
|
|
|
|
is(document.getElementById("panel-container").hidden, false, "Preferences panel should be visible");
|
|
|
|
|
|
|
|
// check if side buttons are visible 6.Verify preference button is depressed and others are not
|
|
|
|
is(document.getElementById("tool-addons").hidden, false, "Addons button must be visible");
|
|
|
|
is(document.getElementById("tool-addons").checked, false, "Addons button must not be pressed");
|
|
|
|
|
|
|
|
is(document.getElementById("tool-downloads").hidden, false, "Downloads button must be visible");
|
|
|
|
is(document.getElementById("tool-downloads").checked, false, "Downloads button must not be pressed");
|
|
|
|
|
|
|
|
is(document.getElementById("tool-preferences").hidden, false, "Preferences button must be visible");
|
|
|
|
is(document.getElementById("tool-preferences").checked, true, "Preferences button must be pressed");
|
|
|
|
|
|
|
|
// Verify back button is exists, is visible and is depressed
|
|
|
|
is(document.getElementById("tool-panel-close").hidden, false, "Panel close button must be visible");
|
|
|
|
is(document.getElementById("tool-panel-close").checked, false, "Panel close button must not be pressed");
|
2010-08-24 01:33:43 -07:00
|
|
|
|
2010-06-11 12:17:14 -07:00
|
|
|
// Now pan preferences pane up/down, left/right
|
|
|
|
// check whether it is in correct position
|
2010-08-24 01:33:43 -07:00
|
|
|
gCurrentTest._prefsScrollbox.getPosition(x, y);
|
|
|
|
ok((x.value == 0 && y.value == 0),"The preferences pane should be visible", "Got " + x.value + " " + y.value + ", expected 0,0");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// Move preferences pane upexpected "+ finalDragOffset +"
|
2010-08-24 01:33:43 -07:00
|
|
|
dragElement(prefsList, w / 2, h / 2, w / 2, h / 4);
|
2010-06-11 12:17:14 -07:00
|
|
|
|
2010-06-30 07:39:14 -07:00
|
|
|
// Check whether it is moved up to the correct view
|
2010-08-24 01:33:43 -07:00
|
|
|
let distance = (h / 2) - (h / 4);
|
|
|
|
gCurrentTest._prefsScrollbox.getPosition(x, y);
|
|
|
|
ok((x.value == 0 && y.value == distance), "Preferences pane is panned up", "Got " + x.value + " " + y.value + ", expected 0," + distance);
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// Move preferences pane down
|
2010-08-24 01:33:43 -07:00
|
|
|
dragElement(prefsList, w / 2, h / 4, w / 2, h / 2);
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// Check whether it goes back to old position
|
2010-08-24 01:33:43 -07:00
|
|
|
gCurrentTest._prefsScrollbox.getPosition(x, y);
|
|
|
|
ok((x.value == 0 && y.value == 0), "Preferences pane is panned down", "Got " + x.value + " " + y.value + ", expected 0,0");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
// Now check whether it is not panned right/left
|
2010-06-11 12:17:14 -07:00
|
|
|
// Move the preferences pane right
|
2010-08-24 01:33:43 -07:00
|
|
|
dragElement(prefsList, w / 2, h / 2, w / 4, h / 2);
|
2010-06-11 12:17:14 -07:00
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
gCurrentTest._prefsScrollbox.getPosition(x, y);
|
|
|
|
ok((x.value == 0 && y.value == 0), "Preferences pane is not panned left", "Got " + x.value + " " + y.value + ", expected 0,0");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// Move the preferences pane left
|
2010-08-24 01:33:43 -07:00
|
|
|
dragElement(prefsList, w / 4, h / 2, w / 2, h / 2);
|
2010-06-11 12:17:14 -07:00
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
gCurrentTest._prefsScrollbox.getPosition(x, y);
|
|
|
|
ok((x.value == 0 && y.value ==0 ), "Preferences pane is not panned right", "Got " + x.value + " " + y.value + ", expected 0,0");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// Close the preferences pane
|
|
|
|
var prefClose = document.getElementById("tool-panel-close");
|
|
|
|
prefClose.click();
|
|
|
|
waitFor(gCurrentTest.finish, function () { return document.getElementById("panel-container").hidden == true; });
|
|
|
|
},
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
finish: function() {
|
2010-06-11 12:17:14 -07:00
|
|
|
// check whether the preferences pane has disappeared
|
|
|
|
is(document.getElementById("panel-container").hidden, true, "Preference pane is now invisible");
|
|
|
|
|
|
|
|
//check if the right sidebar is still visible
|
2010-08-24 01:33:43 -07:00
|
|
|
gCurrentTest._contentScrollbox.getPosition(x, y);
|
|
|
|
todo((x.value == finalDragOffset && y.value == 0), "The right sidebar is still visible",
|
|
|
|
"Got " + x.value + " " + y.value + ", expected " + finalDragOffset + ",0");
|
2010-06-11 12:17:14 -07:00
|
|
|
|
|
|
|
// check whether the preferences open button is not depressed
|
|
|
|
var prefsOpen = document.getElementById("tool-panel-open");
|
|
|
|
is(prefsOpen.checked, false, "Preferences open button must not be depressed");
|
|
|
|
|
2010-08-24 01:33:43 -07:00
|
|
|
Browser.closeTab(this._currentTab);
|
|
|
|
runNextTest();
|
2010-06-11 12:17:14 -07:00
|
|
|
}
|
|
|
|
});
|