gecko-dev/browser/devtools/eyedropper/test/browser_eyedropper_cmd.js
abdelrhman 3990efb3f1 Bug 1111276 - Replace gBrowser.selectedTab.linkedBrowser with gBrowser.selectedBrowser. r=dao
--HG--
extra : rebase_source : d7ef16a16f884458d99dff05efb370694d2ea5e3
2014-12-15 22:05:46 +01:00

60 lines
1.5 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the eyedropper command works
const TESTCASE_URI = TEST_BASE + "color-block.html";
const DIV_COLOR = "#0000FF";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function spawnTest() {
let options = yield helpers.openTab(TESTCASE_URI);
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "eyedropper",
check: {
input: "eyedropper"
},
exec: { output: "" }
},
]);
yield inspectAndWaitForCopy();
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}
function inspectAndWaitForCopy() {
return waitForClipboard(() => {
inspectPage(); // setup: inspect the page
}, DIV_COLOR);
}
function inspectPage() {
let target = document.documentElement;
let win = window;
// get location of the <div> in the content, offset from browser window
let box = gBrowser.selectedBrowser.getBoundingClientRect();
let x = box.left + 100;
let y = box.top + 100;
let dropper = EyedropperManager.getInstance(window);
return dropperStarted(dropper).then(() => {
EventUtils.synthesizeMouse(target, x, y, { type: "mousemove" }, win);
return dropperLoaded(dropper).then(() => {
EventUtils.synthesizeMouse(target, x + 10, y + 10, { type: "mousemove" }, win);
EventUtils.synthesizeMouse(target, x + 10, y + 10, {}, win);
});
})
}