browser/devtools/eyedropper/test/browser_eyedropper_cmd.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Tests that the eyedropper command works
michael@0 5
michael@0 6 const TESTCASE_URI = TEST_BASE + "color-block.html";
michael@0 7 const DIV_COLOR = "#0000FF";
michael@0 8
michael@0 9 function test() {
michael@0 10 return Task.spawn(spawnTest).then(finish, helpers.handleError);
michael@0 11 }
michael@0 12
michael@0 13 function spawnTest() {
michael@0 14 let options = yield helpers.openTab(TESTCASE_URI);
michael@0 15 yield helpers.openToolbar(options);
michael@0 16
michael@0 17 yield helpers.audit(options, [
michael@0 18 {
michael@0 19 setup: "eyedropper",
michael@0 20 check: {
michael@0 21 input: "eyedropper"
michael@0 22 },
michael@0 23 exec: { output: "" }
michael@0 24 },
michael@0 25 ]);
michael@0 26
michael@0 27 yield inspectAndWaitForCopy();
michael@0 28
michael@0 29 yield helpers.closeToolbar(options);
michael@0 30 yield helpers.closeTab(options);
michael@0 31 }
michael@0 32
michael@0 33 function inspectAndWaitForCopy() {
michael@0 34 let deferred = promise.defer();
michael@0 35
michael@0 36 waitForClipboard(DIV_COLOR, () => {
michael@0 37 inspectPage(); // setup: inspect the page
michael@0 38 }, deferred.resolve, deferred.reject);
michael@0 39
michael@0 40 return deferred.promise;
michael@0 41 }
michael@0 42
michael@0 43 function inspectPage() {
michael@0 44 let target = content.document.getElementById("test");
michael@0 45 let win = content.window;
michael@0 46
michael@0 47 EventUtils.synthesizeMouse(target, 20, 20, { type: "mousemove" }, win);
michael@0 48
michael@0 49 let dropper = EyedropperManager.getInstance(window);
michael@0 50
michael@0 51 return dropperLoaded(dropper).then(() => {
michael@0 52 EventUtils.synthesizeMouse(target, 30, 30, { type: "mousemove" }, win);
michael@0 53
michael@0 54 EventUtils.synthesizeMouse(target, 30, 30, {}, win);
michael@0 55 });
michael@0 56 }

mercurial