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