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