Bug 569988 adding test r=ehsan
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 23 Jun 2010 15:15:21 +0900
changeset 44170 38c6287d66820f1121925cf6ef694f53e0d8133c
parent 44169 59a7a98a5a6b940d60af9a9228fd50167448d759
child 44171 18b10e10399dec65ae6717e9d5e7049c20851e45
push id14008
push usermasayuki@d-toybox.com
push dateWed, 23 Jun 2010 06:15:35 +0000
treeherdermozilla-central@38c6287d6682 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs569988
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 569988 adding test r=ehsan
editor/libeditor/text/tests/Makefile.in
editor/libeditor/text/tests/test_bug569988.html
--- a/editor/libeditor/text/tests/Makefile.in
+++ b/editor/libeditor/text/tests/Makefile.in
@@ -41,16 +41,17 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = editor/libeditor/text/tests
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
 		test_bug471722.html \
+		test_bug569988.html \
 		$(NULL)
 
 # disables the key handling test on gtk2 because gtk2 overrides some key events
 # on our editor, and the combinations depend on the system.
 ifneq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 _TEST_FILES += \
 		test_texteditor_keyevent_handling.html \
 		$(NULL)
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/text/tests/test_bug569988.html
@@ -0,0 +1,112 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=569988
+-->
+<head>
+  <title>Test for Bug 569988</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 569988 **/
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(runTest);
+
+var gPromptInput = null;
+var gPromptWindow = null;
+
+function runTest()
+{
+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+
+  function WindowObserver()
+  {
+    Components.classes["@mozilla.org/observer-service;1"].
+               getService(Components.interfaces.nsIObserverService).
+               addObserver(this, "domwindowopened", false);
+  }
+  WindowObserver.prototype = {
+    QueryInterface: function (iid) {
+      if (iid.equals(Components.interfaces.nsIObserver) ||
+          iid.equals(Components.interfaces.nsISupports)) {
+        return this;
+      }
+      throw Components.results.NS_ERROR_NO_INTERFACE;
+    },
+
+    observe: function (subject, topic, data) {
+      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+      if (topic === "domwindowopened") {
+        ok(true, "prompt window is created");
+        gPromptWindow =
+          subject.QueryInterface(Components.interfaces.nsIDOMWindow);
+        gPromptWindow.addEventListener("load", onPromptLoad, false);
+      }
+    }
+  };
+
+  var observer = new WindowObserver();
+
+  prompt("summary", "text");
+  ok(true, "prompt is closed");
+
+  Components.classes["@mozilla.org/observer-service;1"].          
+             getService(Components.interfaces.nsIObserverService).
+             removeObserver(observer, "domwindowopened");
+  SimpleTest.finish();
+}
+
+function onPromptLoad()
+{
+  ok(true, "onPromptLoad is called");
+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+  gPromptWindow.removeEventListener("load", onPromptLoad, false);
+  gPromptInput = gPromptWindow.document.getElementById("loginTextbox");
+  gPromptInput.addEventListener("focus", onPromptFocus, false);
+}
+
+function onPromptFocus()
+{
+  ok(true, "onPromptFocus is called");
+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+  gPromptInput.removeEventListener("focus", onPromptFocus, false);
+  var systemGroup =
+    Components.classes["@mozilla.org/eventlistenerservice;1"].
+      getService(Components.interfaces.nsIEventListenerService).
+      systemEventGroup;
+  gPromptInput.QueryInterface(Components.interfaces.nsIDOM3EventTarget);
+  var isPrevented = false;
+  var listener = {
+    handleEvent: function _hv(aEvent)
+    {
+      isPrevented = aEvent.getPreventDefault();
+    }
+  };
+  gPromptInput.addGroupedEventListener("keypress", listener, false,
+                                       systemGroup);
+  synthesizeKey("VK_ESCAPE", { }, gPromptWindow);
+  gPromptInput.removeGroupedEventListener("keypress", listener, false,
+                                          systemGroup);
+
+  ok(!isPrevented, "ESC key event is prevented by editor");
+  if (isPrevented) {
+    gPromptWindow.close();
+  }
+}
+
+</script>
+</pre>
+</body>
+</html>