toolkit/components/prompts/test/test_bug620145.html
author Justin Dolske <dolske@mozilla.com>
Fri, 07 Jan 2011 19:47:21 -0800
changeset 60233 7b08fef26335b22f23fab430b6938b6f36ec8187
parent 60232 534adf40eb8b29da66218e32ca34a0096940937e
child 60421 e81b9a8b6ccebc341a82a8c31462273ec9c0a885
permissions -rw-r--r--
Fix and reenable test from bug bug 620145. a=bustage

<html>
<head>
  <title>Test for Bug 620145</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript" src="prompt_common.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runtest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=620145">Mozilla Bug 620145</a>
<pre id="test">
</pre>

<button id="button" onmouseup="onButton()">Button</button>

<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();

var testNum = 0;

function onButton() {
  ok(true, "opening alert...");
  alert("hello!");
  ok(true, "...alert done.");
}

function runtest()
{
  // The <button> in this test's HTML opens a prompt when clicked.
  // Here we send the events to simulate clicking it.
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  ok(true, "starting test");
  isTabModal = true;
  startCallbackTimer();

  var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                getInterface(Components.interfaces.nsIDOMWindowUtils);

  var e = document.createEvent("MouseEvent");
  e.initEvent("mousedown", false, false, window, 0, 1, 1, 1, 1,
              false, false, false, false, 0, null);
  utils.dispatchDOMEventViaPresShell($("button"), e, true);
  ok(true, "mousedown sent");

  e = document.createEvent("MouseEvent");
  e.initEvent("mouseup", false, false, window, 0, 1, 1, 1, 1,
              false, false, false, false, 0, null);
  utils.dispatchDOMEventViaPresShell($("button"), e, true);

  ok(true, "mouseup sent");
  SimpleTest.finish();
}

function handleDialog(ui, testNum)
{
  ok(true, "handleDialog sending mouseclick to dialog...");
  synthesizeMouse(ui.button0, 5, 5, { }, ui.button0.ownerDocument.defaultView);
}
</script>

</body>
</html>