Bug 485175 Make geolocation tests more reliable r=dougt

This commit is contained in:
Neil Rashbrook 2009-03-31 17:35:55 +01:00
Родитель 5a0d312bae
Коммит 3ce993ddc0
7 изменённых файлов: 16 добавлений и 30 удалений

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

@ -38,8 +38,6 @@ function check_geolocation(location) {
function getNotificationBox()
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Ci = Components.interfaces;
function getChromeWindow(aWindow) {
@ -64,32 +62,20 @@ function getNotificationBox()
}
function clickNotificationButton(aBar, aButtonName) {
function clickNotificationButton(aButtonIndex) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// This is a bit of a hack. The notification doesn't have an API to
// trigger buttons, so we dive down into the implementation and twiddle
// the buttons directly.
var buttons = aBar.getElementsByTagName("button");
var clicked = false;
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].label == aButtonName) {
buttons[i].click();
clicked = true;
break;
}
}
ok(clicked, "Clicked \"" + aButtonName + "\" button");
var box = getNotificationBox();
ok(box, "Got notification box");
var bar = box.getNotificationWithValue("geolocation");
ok(bar, "Got geolocation notification");
var button = bar.getElementsByTagName("button").item(aButtonIndex);
ok(button, "Got button");
button.doCommand();
}
function clickAccept()
{
clickNotificationButton(getNotificationBox().currentNotification, "Tell them");
}
function clickDeny()
{
clickNotificationButton(getNotificationBox().currentNotification, "Don't tell them");
}
const kAcceptButton = 0;
const kDenyButton = 1;

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

@ -30,7 +30,7 @@ function successCallback(position) {
function accept() {
hasAccepted = true;
clickAccept();
clickNotificationButton(kAcceptButton);
}
SimpleTest.waitForExplicitFinish();

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

@ -34,7 +34,7 @@ function successCallback(position) {
function accept() {
hasAccepted = true;
clickAccept();
clickNotificationButton(kAcceptButton);
}
/** Test for Bug **/

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

@ -37,7 +37,7 @@ SimpleTest.waitForExplicitFinish();
navigator.geolocation.getCurrentPosition(successCallback, failureCallback, null);
// click deny
setTimeout(clickDeny, 50);
setTimeout(clickNotificationButton, 50, kDenyButton);
</script>
</pre>

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

@ -39,7 +39,7 @@ SimpleTest.waitForExplicitFinish();
watchID = navigator.geolocation.getCurrentPosition(successCallback, failureCallback, null);
// click deny
setTimeout(clickDeny, 50);
setTimeout(clickNotificationButton, 50, kDenyButton);
</script>
</pre>

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

@ -50,7 +50,7 @@ SimpleTest.waitForExplicitFinish();
watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);
setTimeout(clickAccept, 10);
setTimeout(clickNotificationButton, 10, kAcceptButton);
setTimeout(clearWatch, 50);

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

@ -56,7 +56,7 @@ navigator.geolocation.watchPosition(successCallback,
errorCallback,
options);
setTimeout(clickAccept, 0);
setTimeout(clickNotificationButton, 10, kAcceptButton);
</script>
</pre>