mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1303167
P5 Fix test that attempts to use setTimeout() during modal dialog. r=smaug
This commit is contained in:
parent
9d590cbd9f
commit
bffc547933
11
toolkit/components/passwordmgr/test/chrome_timeout.js
Normal file
11
toolkit/components/passwordmgr/test/chrome_timeout.js
Normal file
@ -0,0 +1,11 @@
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
addMessageListener('setTimeout', msg => {
|
||||
let timer = Cc['@mozilla.org/timer;1'].createInstance(Ci.nsITimer);
|
||||
timer.init(_ => {
|
||||
sendAsyncMessage('timeout');
|
||||
}, msg.delay, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
});
|
||||
|
||||
sendAsyncMessage('ready');
|
@ -8,6 +8,7 @@ support-files =
|
||||
pwmgr_common.js
|
||||
subtst_master_pass.html
|
||||
subtst_prompt_async.html
|
||||
chrome_timeout.js
|
||||
|
||||
[test_master_password.html]
|
||||
skip-if = toolkit == 'android' # Tests desktop prompts
|
||||
|
@ -233,8 +233,15 @@ function checkTest4A() {
|
||||
|
||||
function checkTest4B_delay() {
|
||||
// Testing a negative, wait a little to give the login manager a chance to
|
||||
// (incorrectly) fill in the form.
|
||||
setTimeout(checkTest4B, 500);
|
||||
// (incorrectly) fill in the form. Note, we cannot use setTimeout()
|
||||
// here because the modal window suspends all window timers. Instead we
|
||||
// must use a chrome script to use nsITimer directly.
|
||||
let chromeURL = SimpleTest.getTestFileURL("chrome_timeout.js");
|
||||
let script = SpecialPowers.loadChromeScript(chromeURL);
|
||||
script.addMessageListener('ready', _ => {
|
||||
script.sendAsyncMessage('setTimeout', { delay: 500 });
|
||||
});
|
||||
script.addMessageListener('timeout', checkTest4B);
|
||||
}
|
||||
|
||||
function checkTest4B() {
|
||||
|
Loading…
Reference in New Issue
Block a user