1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/eyedropper/test/browser_eyedropper_cmd.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Tests that the eyedropper command works 1.8 + 1.9 +const TESTCASE_URI = TEST_BASE + "color-block.html"; 1.10 +const DIV_COLOR = "#0000FF"; 1.11 + 1.12 +function test() { 1.13 + return Task.spawn(spawnTest).then(finish, helpers.handleError); 1.14 +} 1.15 + 1.16 +function spawnTest() { 1.17 + let options = yield helpers.openTab(TESTCASE_URI); 1.18 + yield helpers.openToolbar(options); 1.19 + 1.20 + yield helpers.audit(options, [ 1.21 + { 1.22 + setup: "eyedropper", 1.23 + check: { 1.24 + input: "eyedropper" 1.25 + }, 1.26 + exec: { output: "" } 1.27 + }, 1.28 + ]); 1.29 + 1.30 + yield inspectAndWaitForCopy(); 1.31 + 1.32 + yield helpers.closeToolbar(options); 1.33 + yield helpers.closeTab(options); 1.34 +} 1.35 + 1.36 +function inspectAndWaitForCopy() { 1.37 + let deferred = promise.defer(); 1.38 + 1.39 + waitForClipboard(DIV_COLOR, () => { 1.40 + inspectPage(); // setup: inspect the page 1.41 + }, deferred.resolve, deferred.reject); 1.42 + 1.43 + return deferred.promise; 1.44 +} 1.45 + 1.46 +function inspectPage() { 1.47 + let target = content.document.getElementById("test"); 1.48 + let win = content.window; 1.49 + 1.50 + EventUtils.synthesizeMouse(target, 20, 20, { type: "mousemove" }, win); 1.51 + 1.52 + let dropper = EyedropperManager.getInstance(window); 1.53 + 1.54 + return dropperLoaded(dropper).then(() => { 1.55 + EventUtils.synthesizeMouse(target, 30, 30, { type: "mousemove" }, win); 1.56 + 1.57 + EventUtils.synthesizeMouse(target, 30, 30, {}, win); 1.58 + }); 1.59 +}