summaryrefslogtreecommitdiffstats
path: root/testing/marionette/harness/marionette_harness/www/javascriptPage.html
blob: b47c902c5e6ca9d46ceaaf2eec0fa0d1aab8604e (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <!-- This Source Code Form is subject to the terms of the Mozilla Public
     - License, v. 2.0. If a copy of the MPL was not distributed with this
        - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<head>
    <title>Testing Javascript</title>
    <script type="text/javascript">
        var seen = {};

        function updateContent(input) {
            document.getElementById('result').innerHTML = "<p>" + input.value + "</p>";
        }

        function displayMessage(message) {
            document.getElementById('result').innerHTML = "<p>" + message + "</p>";
        }

        function appendMessage(message) {
            document.getElementById('result').innerHTML += message + " ";
        }

        function register(message) {
          if (!seen[message]) {
            appendMessage(message);
            seen[message] = true;
          }
        }

        function delayedShowHide(delay, show) {
          var blackBox = document.getElementById('clickToHide');
          window.setTimeout(function() {
            blackBox.style.display = show ? '' : 'none';
          }, delay);
        }
    </script>
    <script type="text/javascript">
        var startList = function() {
            // Ugh. Let's hope no-one is faking their user agent when running the tests
            if (navigator.userAgent.indexOf("MSIE") != -1) {
                var navRoot = document.getElementById("nav");
                for (var i = 0; i < navRoot.childNodes.length; i++) {
                    var node = navRoot.childNodes[i];
                    if (node.nodeName == "LI") {
                        node.onmouseover = function() {
                            this.className += " over";
                        };
                        node.onmouseout = function() {
                            this.className = this.className.replace(" over", "");
                        };
                    }
                }
            }
        };
        window.onload=startList;
    </script>
    <style type="text/css">
        #nav {
            padding: 0; margin: 0; list-style: none;
        }
        #nav li {
            float: left; position: relative; width: 10em;
        }
        #nav li ul {
            display: none; position: absolute; top: 1em; left: 0;
        }
        #nav li > ul { top: auto; left: auto; }
        #nav li:hover ul, #nav li.over ul{ display: block; background: white; }
    </style>
</head>
<body>
<h1>Type Stuff</h1>

<div>
    <ul id="nav">
        <li id="menu1">Menu 1
            <ul>
                <li id="item1" onclick="displayMessage('item 1');">Item 1</li>
                <li>Item 2</li>
            </ul>
        </li>
    </ul>
</div>

<div id="resultContainer" height="30">&nbsp;
  <div id="result" style="width:300;height:60">
    <p>&nbsp;</p>
  </div>

</div>
                                                                                         
<div id="formageddon">
    <form action="#">
        Key Up: <input type="text" id="keyUp" onkeyup="javascript:updateContent(this)"/><br/>
        Key Down: <input type="text" id="keyDown" onkeydown="javascript:updateContent(this)"/><br/>
        Key Press: <input type="text" id="keyPress" onkeypress="javascript:updateContent(this)"/><br/>
        Change: <input type="text" id="change" onkeypress="javascript:displayMessage('change')"/><br/>
        <textarea id="keyDownArea" onkeydown="javascript:updateContent(this)" rows="2" cols="15"></textarea>
        <textarea id="keyPressArea" onkeypress="javascript:updateContent(this)" rows="2" cols="15"></textarea>
        <textarea id="keyUpArea" onkeyup="javascript:updateContent(this)" rows="2" cols="15"></textarea>
        <select id="selector" onchange="javascript:updateContent(this)">
            <option value="foo">Foo</option>
            <option value="bar">Bar</option>
        </select>
        <input type="checkbox" id="checkbox" value="checkbox thing" onchange="javascript:updateContent(this)"/>
        <input id="clickField" type="text" onclick="document.getElementById('clickField').value='Clicked';" value="Hello"/>
        <input id="doubleClickField" type="text" onclick="document.getElementById('doubleClickField').value='Clicked';" ondblclick="document.getElementById('doubleClickField').value='DoubleClicked';" oncontextmenu="document.getElementById('doubleClickField').value='ContextClicked'; return false;" value="DoubleHello"/>
        <input id="clearMe" value="Something" onchange="displayMessage('Cleared')"/>
    </form>
</div>

<div>
    <p><a href="#" onclick="javascript:document.title='Changed'">Change the page title!</a></p>

    <p><a onclick="javascript:document.title='Changed'" id="nohref">No href</a></p>

    <p><a id="updatediv" href="#" onclick="javascript:document.getElementById('dynamo').innerHTML = 'Fish and chips!';">Update a
        div</a></p>
</div>

<div id="dynamo">What's for dinner?</div>

<div id="mousedown" onmousedown="javascript:displayMessage('mouse down');">
    <p>Click for the mouse down event</p>
    <span><p id="child">Here's some text</p></span>
</div>

<div id="mouseup" onmouseup="javascript:displayMessage('mouse up');">
    <p>Click for the mouse up event</p>
</div>

<div id="mouseclick" onclick="javascript:displayMessage('mouse click');">
    <p>Click for the mouse click event</p>
</div>

<div id="mousebutton">
    <p>Click to show button</p>
</div>

<div id="error" onclick="document.getElementById('doesnotexist').innerHTML = 'cheese';">
    Clicking this causes a JS exception in the click handler
</div>

<div>
  <form action="resultPage.html" id="on-form">
    <input id="theworks"
           onfocus="appendMessage('focus')"
           onkeydown="appendMessage('keydown')"
           onkeypress="appendMessage('keypress')"
           onkeyup="appendMessage('keyup')"
           onblur="appendMessage('blur')"
           onchange="appendMessage('change')"
           />

    <input id="changeable" name="changeable" onfocus="appendMessage('focus')" onchange="appendMessage('change')" onblur="appendMessage('blur')"/>
           
    <button type="button" id="plainButton" 
    		onfocus="appendMessage('focus')"
           	onkeydown="appendMessage('keydown')"
           	onkeypress="appendMessage('keypress')"
           	onkeyup="appendMessage('keyup')"
           	onblur="appendMessage('blur')"
           	onclick="appendMessage('click')"
           	onmousedown="appendMessage('mousedown ')" 
           	onmouseup="appendMessage('mouseup ')"
            onmouseover="register('mouseover ')"
            onmousemove="register('mousemove ')"
    >
        <b>Go somewhere</b>
    </button>
    <button type="submit" id="submittingButton"><emph>submit</emph></button>
    <button type="button" id="jsSubmitButton" onclick="javascript:document.getElementById('on-form').submit();">Submitomatic</button>

    <button type="button" id="switchFocus" onclick="document.getElementById('theworks').focus();">Switch focus</button>
    <button type="button" onclick="var element = document.getElementById('switchFocus'); var clickEvent = document.createEvent('MouseEvents'); clickEvent.initMouseEvent('click', true, true, null, 0, 0, 0, 0, 0,false, false, false, false, 0, element);element.dispatchEvent(clickEvent);">Do magic</button><br/>
    <label id="labelForCheckbox" for="labeledCheckbox" onclick="appendMessage('labelclick')">Toggle checkbox</label><input type="checkbox" id="labeledCheckbox" onclick="appendMessage('chboxclick')"/>
  </form>
  
  <form action="javascriptPage.html" id="submitListeningForm" onsubmit="appendMessage('form-onsubmit '); return false;">
    <p>
      <input id="submitListeningForm-text" type="text" onsubmit="appendMessage('text-onsubmit ')" onclick="appendMessage('text-onclick ');" />
      <input id="submitListeningForm-submit" type="submit" onsubmit="appendMessage('submit-onsubmit ')" onclick="appendMessage('submit-onclick ');" />
    </p>
  </form>
</div>

<p id="suppressedParagraph" style="display: none">A paragraph suppressed using CSS display=none</p>

<div>
    <p id="displayed">Displayed</p>

    <form action="#"><input type="hidden" name="hidden" /> </form>

    <p id="none" style="display: none;">Display set to none</p>

    <p id="hidden" style="visibility: hidden;">Hidden</p>

    <div id="hiddenparent" style="height: 2em; display: none;">
      <div id="hiddenchild">
        <a href="#" id="hiddenlink">ok</a>
      </div>
    </div>
    
    <div style="visibility: hidden;">
      <span>
        <input id="unclickable" />
        <input type="checkbox" id="untogglable" checked="checked" />Check box you can't see
      </span>
    </div>

    <p id="outer" style="visibility: hidden">A <b id="visibleSubElement" style="visibility: visible">sub-element that is explicitly visible</b> using CSS visibility=visible</p>
</div>

<div>
    <form>
        <input type="text" id="keyReporter" size="80"
               onkeyup="appendMessage('up: ' + event.keyCode)"
               onkeypress="appendMessage('press: ' + event.keyCode)"
               onkeydown="displayMessage(''); appendMessage('down: ' + event.keyCode)" />
        <input name="suppress" onkeydown="if (event.preventDefault) event.preventDefault(); event.returnValue = false; return false;" onkeypress="appendMessage('press');"/>
    </form>
</div>

<!-- Used for testing styles -->
<div style="background-color: green;" id="green-parent">
  <p id="style1">This should be greenish</p>
    <ul>
      <li id="green-item">So should this</li>
      <li id="red-item" style="background-color: red;">But this is red</li>
    </ul>
</div>

<a href="#" id="close" onclick="window.close();">Close window</a>

<div id="delete" onclick="var d = document.getElementById('deleted'); this.removeChild(d);">
    <p id="deleted">I should be deleted when you click my containing div</p>
    <p>Whereas, I should not</p>
</div>

<div>
    <span id="hideMe" onclick="this.style.display = 'none';">Click to hide me.</span>
</div>

<div style="margin-top: 10px;">
  Click actions delayed by 3000ms:
  <div id="clickToShow" onclick="delayedShowHide(3000, true);"
       style="float: left;width: 100px;height:100px;border: 1px solid black;">
    Click to show black box
  </div>
  <div id="clickToHide" onclick="delayedShowHide(3000, false);"
       style="float: left;width: 100px;height:100px;border: 1px solid black;
              background-color: black; color: white; display: none;">
    Click to hide black box
  </div>
  <div style="clear: both"></div>
</div>

<a id="new_window" onmouseup="window.open('closeable_window.html', 'close_me')" href="#">Click me to open a new window</a>

<a id="throwing-mouseover" onmouseover="throw new Error()" href="#throwing-mouseover">Mouse over me will throw a JS error</a>

<div id="parent">
    <span id="movable" onmouseover="var p = document.getElementById('movable'); displayMessage('parent matches? ' + (p != event.relatedTarget));">
        Click on me to show the related target
    </span>
</div>

<div id="zero" style="width:0;height:0">
  <div>
    <img src="map.png">
  </div>
</div>

<input type='text' id='notDisplayed' style='display:none'>
</body>
</html>