michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests that the eyedropper command works michael@0: michael@0: const TESTCASE_URI = TEST_BASE + "color-block.html"; michael@0: const DIV_COLOR = "#0000FF"; michael@0: michael@0: function test() { michael@0: return Task.spawn(spawnTest).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: function spawnTest() { michael@0: let options = yield helpers.openTab(TESTCASE_URI); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: yield helpers.audit(options, [ michael@0: { michael@0: setup: "eyedropper", michael@0: check: { michael@0: input: "eyedropper" michael@0: }, michael@0: exec: { output: "" } michael@0: }, michael@0: ]); michael@0: michael@0: yield inspectAndWaitForCopy(); michael@0: michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: } michael@0: michael@0: function inspectAndWaitForCopy() { michael@0: let deferred = promise.defer(); michael@0: michael@0: waitForClipboard(DIV_COLOR, () => { michael@0: inspectPage(); // setup: inspect the page michael@0: }, deferred.resolve, deferred.reject); michael@0: michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function inspectPage() { michael@0: let target = content.document.getElementById("test"); michael@0: let win = content.window; michael@0: michael@0: EventUtils.synthesizeMouse(target, 20, 20, { type: "mousemove" }, win); michael@0: michael@0: let dropper = EyedropperManager.getInstance(window); michael@0: michael@0: return dropperLoaded(dropper).then(() => { michael@0: EventUtils.synthesizeMouse(target, 30, 30, { type: "mousemove" }, win); michael@0: michael@0: EventUtils.synthesizeMouse(target, 30, 30, {}, win); michael@0: }); michael@0: }