Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* vim: set ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
5 const TESTCASE_URI = TEST_BASE + "color-block.html";
6 const DIV_COLOR = "#0000FF";
8 /**
9 * Test basic eyedropper widget functionality:
10 * - Opening eyedropper and pressing ESC closes the eyedropper
11 * - Opening eyedropper and clicking copies the center color
12 */
13 function test() {
14 addTab(TESTCASE_URI).then(testEscape);
15 }
17 function testEscape() {
18 let dropper = new Eyedropper(window);
20 dropper.once("destroy", (event) => {
21 ok(true, "escape closed the eyedropper");
23 // now test selecting a color
24 testSelect();
25 });
27 inspectPage(dropper, false).then(pressESC);
28 }
30 function testSelect() {
31 let dropper = new Eyedropper(window);
33 dropper.once("select", (event, color) => {
34 is(color, DIV_COLOR, "correct color selected");
35 });
37 // wait for DIV_COLOR to be copied to the clipboard then finish the test.
38 waitForClipboard(DIV_COLOR, () => {
39 inspectPage(dropper); // setup: inspect the page
40 }, finish, finish);
41 }
43 /* Helpers */
45 function inspectPage(dropper, click=true) {
46 dropper.open();
48 let target = content.document.getElementById("test");
49 let win = content.window;
51 EventUtils.synthesizeMouse(target, 20, 20, { type: "mousemove" }, win);
53 return dropperLoaded(dropper).then(() => {
54 EventUtils.synthesizeMouse(target, 30, 30, { type: "mousemove" }, win);
56 if (click) {
57 EventUtils.synthesizeMouse(target, 30, 30, {}, win);
58 }
59 });
60 }
62 function pressESC() {
63 EventUtils.synthesizeKey("VK_ESCAPE", { });
64 }