diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/browserElement_PromptCheck.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/browser-element/mochitest/browserElement_PromptCheck.js')
-rw-r--r-- | dom/browser-element/mochitest/browserElement_PromptCheck.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_PromptCheck.js b/dom/browser-element/mochitest/browserElement_PromptCheck.js new file mode 100644 index 000000000..d6edde09f --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_PromptCheck.js @@ -0,0 +1,59 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that alertCheck (i.e., alert with the opportunity to opt out of future +// alerts), promptCheck, and confirmCheck work. We do this by spamming +// alerts/prompts/confirms from inside an <iframe mozbrowser>. +// +// At the moment, we treat alertCheck/promptCheck/confirmCheck just like a +// normal alert. But it's different to nsIPrompt! + +"use strict"; + +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); +browserElementTestHelpers.addPermission(); + +function runTest() +{ + var iframe = document.createElement('iframe'); + iframe.setAttribute('mozbrowser', 'true'); + document.body.appendChild(iframe); + + var numPrompts = 0; + iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { + is(e.detail.message, String(numPrompts), "prompt message"); + if (numPrompts / 10 < 1) { + is(e.detail.promptType, 'alert'); + } + else if (numPrompts / 10 < 2) { + is(e.detail.promptType, 'confirm'); + } + else { + is(e.detail.promptType, 'prompt'); + } + + numPrompts++; + if (numPrompts == 30) { + SimpleTest.finish(); + } + }); + + iframe.src = + 'data:text/html,<html><body><script>\ + addEventListener("load", function() { \ + setTimeout(function() { \ + var i = 0; \ + for (; i < 10; i++) { alert(i); } \ + for (; i < 20; i++) { confirm(i); } \ + for (; i < 30; i++) { prompt(i); } \ + }); \ + }); \ + </scr' + 'ipt></body></html>'; +} + +// The test harness sets dom.successive_dialog_time_limit to 0 for some bizarre +// reason. That's not normal usage, and it keeps us from testing alertCheck! +addEventListener('testready', function() { + SpecialPowers.pushPrefEnv({'set': [['dom.successive_dialog_time_limit', 10]]}, runTest); +}); |