1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/text/tests/test_bug569988.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=569988 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 569988</title> 1.11 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script type="application/javascript"> 1.23 + 1.24 +/** Test for Bug 569988 **/ 1.25 + 1.26 +SimpleTest.waitForExplicitFinish(); 1.27 +SimpleTest.waitForFocus(runTest); 1.28 + 1.29 +var gPromptInput = null; 1.30 + 1.31 +function runTest() 1.32 +{ 1.33 + var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"]. 1.34 + getService(SpecialPowers.Ci.nsIObserverService); 1.35 + 1.36 + os.addObserver(onPromptLoad, "common-dialog-loaded", false); 1.37 + os.addObserver(onPromptLoad, "tabmodal-dialog-loaded", false); 1.38 + 1.39 + info("opening prompt..."); 1.40 + prompt("summary", "text"); 1.41 + info("prompt is closed"); 1.42 + 1.43 + os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded"); 1.44 + os.removeObserver(onPromptLoad, "common-dialog-loaded"); 1.45 + SimpleTest.finish(); 1.46 +} 1.47 + 1.48 +function onPromptLoad(subject, topic, data) 1.49 +{ 1.50 + ok(true, "onPromptLoad is called"); 1.51 + gPromptInput = subject.Dialog.ui.loginTextbox; 1.52 + gPromptInput.addEventListener("focus", onPromptFocus, false); 1.53 + // shift focus to ensure it fires. 1.54 + subject.Dialog.ui.button0.focus(); 1.55 + gPromptInput.focus(); 1.56 +} 1.57 + 1.58 +function onPromptFocus() { 1.59 + ok(true, "onPromptFocus is called"); 1.60 + gPromptInput.removeEventListener("focus", onPromptFocus, false); 1.61 + 1.62 + var listener = { 1.63 + handleEvent: function _hv(aEvent) 1.64 + { 1.65 + var isPrevented = aEvent.defaultPrevented; 1.66 + ok(!isPrevented, "ESC key event is prevented by editor"); 1.67 + SpecialPowers.removeSystemEventListener(gPromptInput, "keypress", 1.68 + listener, false); 1.69 + } 1.70 + }; 1.71 + SpecialPowers.addSystemEventListener(gPromptInput, "keypress", listener, 1.72 + false); 1.73 + info("sending key"); 1.74 + synthesizeKey("VK_ESCAPE", { }, gPromptInput.ownerDocument.defaultView); 1.75 +} 1.76 + 1.77 +</script> 1.78 +</pre> 1.79 +</body> 1.80 +</html>