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