browser_jsterm_middle_click_paste.js (1134B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Test that pasting clipboard content into input with middle-click works. 5 6 "use strict"; 7 8 const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>Web Console test paste on middle-click`; 9 10 add_task(async function () { 11 await pushPref("devtools.selfxss.count", 5); 12 13 // Enable pasting with middle-click. 14 await pushPref("middlemouse.paste", true); 15 16 const hud = await openNewTabAndConsole(TEST_URI); 17 const { jsterm } = hud; 18 19 info("Set clipboard content"); 20 const clipboardContent = "test clipboard content"; 21 setClipboardText(clipboardContent); 22 23 info("Middle-click on the console input"); 24 const node = jsterm.node; 25 26 EventUtils.synthesizeMouse(node, 30, 10, { button: 1 }, hud.iframeWindow); 27 is( 28 getInputValue(hud), 29 clipboardContent, 30 "clipboard content was pasted in the console input" 31 ); 32 }); 33 34 function setClipboardText(text) { 35 const helper = SpecialPowers.Cc[ 36 "@mozilla.org/widget/clipboardhelper;1" 37 ].getService(SpecialPowers.Ci.nsIClipboardHelper); 38 helper.copyString(text); 39 }