dom/tests/mochitest/chrome/test_clipboard_events_chrome.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:6c2dadffc58d
1 <html>
2 <body onload="runTest()">
3
4 <script type="application/javascript"
5 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="application/javascript"
7 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
8
9 <script>
10 // This test checks that the dom.event.clipboardevents.enabled does not apply to chrome shells.
11
12 SimpleTest.waitForExplicitFinish();
13 function runTest()
14 {
15 SpecialPowers.setBoolPref("dom.event.clipboardevents.enabled", false);
16 window.open("data:text/html,<body onload='window.opener.doChecks(this)'><input id='i' value='Sample Text'></body>",
17 "_blank", "chrome,width=200,height=200");
18 }
19
20 var event_fired = false;
21
22 function doChecks(win)
23 {
24 var windowFocused = function() {
25 var textbox = win.document.getElementById("i");
26 textbox.value = "Sample Text";
27
28 textbox.oncut = function() { event_fired = true; };
29 textbox.oncopy = function() { event_fired = true; };
30 textbox.onpaste = function() { event_fired = true; };
31
32 textbox.select();
33 textbox.focus();
34
35 textbox.setSelectionRange(1, 4);
36 synthesizeKey("x", {accelKey: 1}, win);
37 is(textbox.value, "Sle Text", "cut changed text when preference is disabled");
38 ok(event_fired, "cut event fired when preference is disabled")
39
40 event_fired = false;
41 textbox.setSelectionRange(4, 6);
42 synthesizeKey("c", {accelKey: 1}, win);
43 is(textbox.value, "Sle Text", "cut changed text when preference is disabled");
44 ok(event_fired, "copy event fired when preference is disabled")
45
46 event_fired = false;
47 textbox.setSelectionRange(1, 4);
48 synthesizeKey("v", {accelKey: 1}, win);
49 is(textbox.value, "STeText", "paste changed text when preference is disabled");
50 ok(event_fired, "paste event fired when preference is disabled")
51
52 SpecialPowers.clearUserPref("dom.event.clipboardevents.enabled");
53 win.close();
54 SimpleTest.finish();
55 }
56
57 SimpleTest.waitForFocus(windowFocused, win);
58 }
59
60 </script>
61
62 <p id="display"></p>
63 </body></html>

mercurial