зеркало из https://github.com/mozilla/gecko-dev.git
Bug 764421 - poll with setInterval instead of using setTimeout in browser_bug743421.js; r=jaws
This commit is contained in:
Родитель
4b91a0a661
Коммит
4090b50573
|
@ -42,7 +42,8 @@ function test1a() {
|
|||
ok(!popupNotification, "Test 1a, Should not have a click-to-play notification");
|
||||
var plugin = gTestBrowser.contentWindow.addPlugin();
|
||||
|
||||
setTimeout(test1b, 500);
|
||||
var condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
|
||||
waitForCondition(condition, test1b, "Test 1a, Waited too long for plugin notification");
|
||||
}
|
||||
|
||||
function test1b() {
|
||||
|
@ -53,7 +54,7 @@ function test1b() {
|
|||
ok(!objLoadingContent.activated, "Test 1b, Plugin should not be activated");
|
||||
|
||||
popupNotification.mainAction.callback();
|
||||
setTimeout(test1c, 500);
|
||||
test1c();
|
||||
}
|
||||
|
||||
function test1c() {
|
||||
|
@ -61,7 +62,9 @@ function test1c() {
|
|||
ok(!popupNotification, "Test 1c, Should not have a click-to-play notification");
|
||||
var plugin = gTestBrowser.contentWindow.addPlugin();
|
||||
|
||||
setTimeout(test1d, 500);
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
var condition = function() objLoadingContent.activated;
|
||||
waitForCondition(condition, test1d, "Test 1c, Waited too long for plugin activation");
|
||||
}
|
||||
|
||||
function test1d() {
|
||||
|
@ -82,7 +85,9 @@ function test1e() {
|
|||
ok(!popupNotification, "Test 1e, Should not have a click-to-play notification");
|
||||
var plugin = gTestBrowser.contentWindow.addPlugin();
|
||||
|
||||
setTimeout(test1f, 500);
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
var condition = function() objLoadingContent.activated;
|
||||
waitForCondition(condition, test1f, "Test 1e, Waited too long for plugin activation");
|
||||
}
|
||||
|
||||
function test1f() {
|
||||
|
@ -93,8 +98,10 @@ function test1f() {
|
|||
ok(objLoadingContent.activated, "Test 1f, Plugin should be activated");
|
||||
|
||||
gTestBrowser.contentWindow.history.replaceState({}, "", "replacedState");
|
||||
gTestBrowser.contentWindow.addPlugin();
|
||||
setTimeout(test1g, 500);
|
||||
var plugin = gTestBrowser.contentWindow.addPlugin();
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
var condition = function() objLoadingContent.activated;
|
||||
waitForCondition(condition, test1g, "Test 1f, Waited too long for plugin activation");
|
||||
}
|
||||
|
||||
function test1g() {
|
||||
|
|
|
@ -213,21 +213,6 @@ function test8() {
|
|||
prepareTest(test9a, gTestRoot + "plugin_test2.html");
|
||||
}
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg) {
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= 500) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
if (condition()) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 10);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
||||
|
||||
// Tests that activating one click-to-play plugin will activate only that plugin (part 1/3)
|
||||
function test9a() {
|
||||
var notificationBox = gBrowser.getNotificationBox(gTestBrowser);
|
||||
|
|
|
@ -72,3 +72,18 @@ function closeToolbarCustomizationUI(aCallback, aBrowserWin) {
|
|||
button.focus();
|
||||
button.doCommand();
|
||||
}
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg) {
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= 30) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
if (condition()) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 100);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче