dom/tests/mochitest/chrome/test_clipboard_events_chrome.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <html>
     2 <body onload="runTest()">
     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>
     9 <script>
    10 // This test checks that the dom.event.clipboardevents.enabled does not apply to chrome shells.
    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 }
    20 var event_fired = false;
    22 function doChecks(win)
    23 {
    24   var windowFocused = function() {
    25     var textbox = win.document.getElementById("i");
    26     textbox.value = "Sample Text";
    28     textbox.oncut = function() { event_fired = true; };
    29     textbox.oncopy = function() { event_fired = true; };
    30     textbox.onpaste = function() { event_fired = true; };
    32     textbox.select();
    33     textbox.focus();
    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")
    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")
    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")
    52     SpecialPowers.clearUserPref("dom.event.clipboardevents.enabled");
    53     win.close();
    54     SimpleTest.finish();
    55   }
    57   SimpleTest.waitForFocus(windowFocused, win);
    58 }
    60 </script>
    62 <p id="display"></p>
    63 </body></html>

mercurial