File: test_bug625187.html

package info (click to toggle)
wine-gecko-2.21 2.21%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 646,272 kB
  • ctags: 630,086
  • sloc: cpp: 2,895,786; ansic: 1,502,970; python: 156,675; asm: 115,373; java: 111,421; sh: 63,309; xml: 62,872; makefile: 58,685; perl: 19,182; objc: 3,461; yacc: 2,051; lex: 979; pascal: 929; exp: 449; php: 244; lisp: 228; awk: 211; sed: 26; csh: 21; ada: 16; ruby: 3
file content (104 lines) | stat: -rw-r--r-- 3,338 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<html>
<head>
  <title>Test for Bug 625187</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">
<!--
   - Any copyright is dedicated to the Public Domain.
   - http://creativecommons.org/publicdomain/zero/1.0/
   -
   - Contributor(s):
   -   Mihai Sucan <mihai.sucan@gmail.com>
   -->
</head>
<body onload="runtest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=625187">Mozilla Bug 625187</a>

<p><button onclick="alert('hello world')">Button</button></p>

<iframe id="iframe_diff_origin" src="http://example.com/tests/toolkit/components/prompts/test/bug625187_iframe.html"></iframe>

<iframe id="iframe_same_origin" src="bug625187_iframe.html"></iframe>

<pre id="test"></pre>

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

var testNum = 0;
var dialogNum = 0;

function hasTabModalPrompts() {
  var prefName = "prompts.tab_modal.enabled";
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  Components.utils.import("resource://gre/modules/Services.jsm");
  return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL &&
         Services.prefs.getBoolPref(prefName);
}

function runtest()
{
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

  isTabModal = hasTabModalPrompts();

  // This test depends on tab modal prompts being enabled.
  if (!isTabModal) {
    todo(false, "Test disabled when tab modal prompts are not enabled.");
    SimpleTest.finish();
    return;
  }

  startCallbackTimer();

  var button = document.querySelector("button");
  dispatchMouseEvent(button, "click");

  startCallbackTimer();

  var iframe = document.getElementById("iframe_diff_origin");
  button = iframe.contentWindow.document.getElementById("btn1");
  dispatchMouseEvent(button, "click");

  startCallbackTimer();

  iframe = document.getElementById("iframe_same_origin");
  button = iframe.contentWindow.document.getElementById("btn1");
  dispatchMouseEvent(button, "click");

  startCallbackTimer();

  button = iframe.contentWindow.document.getElementById("btn2");
  dispatchMouseEvent(button, "click");

  SimpleTest.finish();
}

function handleDialog(ui)
{
  dialogNum++;
  if (dialogNum == 1 || dialogNum == 3 || dialogNum == 4)
    is(ui.infoTitle.getAttribute("hidden"), "true",
       "dialog #" + dialogNum + ": the tabprompt infoTitle element is hidden");
  else if (dialogNum == 2)
    ok(!ui.infoTitle.hasAttribute("hidden"),
       "dialog #" + dialogNum + ": the tabprompt infoTitle element is not hidden");

  synthesizeMouse(ui.button0, 2, 2, {}, ui.button0.ownerDocument.defaultView);
}

function dispatchMouseEvent(target, type)
{
  var win = target.ownerDocument.defaultView;
  var e = document.createEvent("MouseEvent");
  e.initEvent(type, false, false, win, 0, 1, 1, 1, 1,
              false, false, false, false, 0, null);
  var utils = SpecialPowers.getDOMWindowUtils(win);
  utils.dispatchDOMEventViaPresShell(target, e, true);
}
</script>
</body>
</html>