Bug 522271: --browser-chrome Mochitests on Fennec (bookmark popup) [r=gavin.sharp]

This commit is contained in:
Mark Finkle 2009-10-16 00:00:14 -04:00
Родитель 994216a3a1
Коммит f79b939fec
4 изменённых файлов: 112 добавлений и 20 удалений

Просмотреть файл

@ -105,7 +105,7 @@ gTests.push({
gCurrentTest._currenttab.browser.addEventListener("pageshow",
function() {
gCurrentTest._currenttab.browser.removeEventListener("pageshow", arguments.callee, true);
todo(gCurrentTest._currenttab.browser.currentURI.spec, testURL_01, "Opened the right bookmark");
todo_is(gCurrentTest._currenttab.browser.currentURI.spec, testURL_01, "Opened the right bookmark");
Browser.closeTab(gCurrentTest._currenttab);
@ -203,6 +203,7 @@ gTests.push({
// Case: Test removing existing bookmark
gTests.push({
desc: "Test removing existing bookmark",
bookmarkitem: null,
run: function() {
// Open the bookmark list
@ -216,10 +217,14 @@ gTests.push({
onBookmarksReady: function() {
var bookmarkitems = document.getElementById("bookmark-items");
var bookmarkitem = document.getAnonymousElementByAttribute(bookmarkitems, "uri", testURL_02);
EventUtils.synthesizeMouse(bookmarkitem, bookmarkitem.clientWidth / 2, bookmarkitem.clientHeight / 2, {});
gCurrentTest.bookmarkitem = document.getAnonymousElementByAttribute(bookmarkitems, "uri", testURL_02);
EventUtils.synthesizeMouse(gCurrentTest.bookmarkitem, gCurrentTest.bookmarkitem.clientWidth / 2, gCurrentTest.bookmarkitem.clientHeight / 2, {});
var removebutton = document.getAnonymousElementByAttribute(bookmarkitem, "anonid", "close-button");
waitFor(gCurrentTest.onEditorReady, function() { return gCurrentTest.bookmarkitem.isEditing == true; });
},
onEditorReady: function() {
var removebutton = document.getAnonymousElementByAttribute(gCurrentTest.bookmarkitem, "anonid", "remove-button");
removebutton.click();
var bookmark = PlacesUtils.getMostRecentBookmarkForURI(uri(testURL_02));

Просмотреть файл

@ -45,14 +45,14 @@ function runNextTest() {
}
//------------------------------------------------------------------------------
// Case: Test adding tags via star icon
// Case: Test appearance and behavior of the bookmark popup
gTests.push({
desc: "Test adding tags via star icon",
desc: "Test appearance and behavior of the bookmark popup",
_currenttab: null,
run: function() {
this._currenttab = Browser.addTab(testURL_02, true);
var handleEvent = function() {
function handleEvent() {
gCurrentTest._currenttab.browser.removeEventListener("load", handleEvent, true);
gCurrentTest.onPageLoad();
};
@ -63,6 +63,85 @@ gTests.push({
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupReady1, function() { return document.getElementById("bookmark-popup").hidden == false; });
},
onPopupReady1: function() {
// Popup should auto-hide after 2 seconds on the initial bookmark with star
setTimeout(gCurrentTest.onPopupGone, 3000);
},
onPopupGone: function() {
// Make sure it's hidden again
is(document.getElementById("bookmark-popup").hidden, true, "Bookmark popup should be auto-hidden");
// Let's make it appear again and continue the test
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupReady2, function() { return document.getElementById("bookmark-popup").hidden == false; });
},
onPopupReady2: function() {
// Let's make it disappear again by clicking the star again
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupGone2, function() { return document.getElementById("bookmark-popup").hidden == true; });
},
onPopupGone2: function() {
// Make sure it's hidden again
is(document.getElementById("bookmark-popup").hidden, true, "Bookmark popup should be hidden by clicking star");
// Let's make it appear again and continue the test
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupReady3, function() { return document.getElementById("bookmark-popup").hidden == false; });
},
onPopupReady3: function() {
// Let's make it disappear again by clicking somewhere
var contentarea = document.getElementById("tile-container");
EventUtils.synthesizeMouse(contentarea, contentarea.clientWidth / 2, contentarea.clientHeight / 2, {});
waitFor(gCurrentTest.onPopupGone3, function() { return document.getElementById("bookmark-popup").hidden == true; });
},
onPopupGone3: function() {
// Make sure it's hidden again
is(document.getElementById("bookmark-popup").hidden, true, "Bookmark popup should be hidden by clicking in content");
BrowserUI.closeTab(this._currenttab);
runNextTest();
}
});
//------------------------------------------------------------------------------
// Case: Test adding tags via star icon
gTests.push({
desc: "Test adding tags via star icon",
_currenttab: null,
run: function() {
this._currenttab = Browser.addTab(testURL_02, true);
function handleEvent() {
gCurrentTest._currenttab.browser.removeEventListener("load", handleEvent, true);
gCurrentTest.onPageLoad();
};
this._currenttab.browser.addEventListener("load", handleEvent , true);
},
onPageLoad: function() {
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupReady, function() { return document.getElementById("bookmark-popup").hidden == false; });
},
onPopupReady: function() {
var editbutton = document.getElementById("bookmark-popup-edit");
editbutton.click();
@ -97,7 +176,7 @@ gTests.push({
run: function() {
this._currenttab = Browser.addTab(testURL_02, true);
var handleEvent = function() {
function handleEvent() {
gCurrentTest._currenttab.browser.removeEventListener("load", handleEvent, true);
gCurrentTest.onPageLoad();
};
@ -108,6 +187,10 @@ gTests.push({
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupReady, function() { return document.getElementById("bookmark-popup").hidden == false; });
},
onPopupReady: function() {
var editbutton = document.getElementById("bookmark-popup-edit");
editbutton.click();
@ -145,7 +228,7 @@ gTests.push({
run: function() {
this._currenttab = Browser.addTab(testURL_01, true);
var handleEvent = function() {
function handleEvent() {
gCurrentTest._currenttab.browser.removeEventListener("load", handleEvent, true);
gCurrentTest.onPageLoad();
};
@ -156,6 +239,10 @@ gTests.push({
var starbutton = document.getElementById("tool-star");
starbutton.click();
waitFor(gCurrentTest.onPopupReady, function() { return document.getElementById("bookmark-popup").hidden == false; });
},
onPopupReady: function() {
var removebutton = document.getElementById("bookmark-popup-remove");
removebutton.click();

Просмотреть файл

@ -52,7 +52,7 @@ gTests.push({
run: function() {
this._currenttab = Browser.addTab(testURL_02, true);
var handleEvent = function() {
function handleEvent() {
gCurrentTest._currenttab.browser.removeEventListener("load", handleEvent, true);
gCurrentTest.onPageLoad();
};

Просмотреть файл

@ -6,16 +6,16 @@ const Ci = Components.interfaces;
//------------------------------------------------------------------------------
// Entry point (must be named "test")
function test() {
is(window.location.href, "chrome://browser/content/browser.xul", "Main window should be browser.xul");
window.focus();
let browser = Browser.selectedBrowser;
isnot(browser, null, "Should have a browser");
is(browser.currentURI.spec, Browser.selectedTab.browser.currentURI.spec, "selectedBrowser == selectedTab.browser");
testContentContainerSize();
is(window.location.href, "chrome://browser/content/browser.xul", "Main window should be browser.xul");
window.focus();
let browser = Browser.selectedBrowser;
isnot(browser, null, "Should have a browser");
is(browser.currentURI.spec, Browser.selectedTab.browser.currentURI.spec, "selectedBrowser == selectedTab.browser");
testContentContainerSize();
}
function testContentContainerSize() {