Bug 1349483 - fix colorpicker eyedropper when devtools are in a window host;r=pbro

MozReview-Commit-ID: CwfZaIsGoBW

--HG--
extra : rebase_source : 17eae1fea9b6552d67907d09a04d8c3eefb01aef
This commit is contained in:
Julian Descottes 2018-01-09 19:30:11 +01:00
parent 0aa5ebf407
commit 100cde3ae6
2 changed files with 29 additions and 5 deletions

View File

@ -34,10 +34,31 @@ const ORIGINAL_COLOR = "rgb(255, 0, 153)";
// #ff5
const EXPECTED_COLOR = "rgb(255, 255, 85)";
registerCleanupFunction(() => {
// Restore the default Toolbox host position after the test.
Services.prefs.clearUserPref("devtools.toolbox.host");
});
add_task(function* () {
info("Add the test tab, open the rule-view and select the test node");
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {testActor, inspector, view} = yield openRuleView();
let url = "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI);
yield addTab(url);
let {testActor, inspector, view, toolbox} = yield openRuleView();
yield runTest(testActor, inspector, view);
info("Reload the page to restore the initial state");
yield navigateTo(inspector, url);
info("Change toolbox host to WINDOW");
yield toolbox.switchHost("window");
yield runTest(testActor, inspector, view);
});
function* runTest(testActor, inspector, view) {
yield selectNode("#div2", inspector);
info("Get the background-color property from the rule-view");
@ -66,7 +87,7 @@ add_task(function* () {
ok(!tooltip.isVisible(), "color picker tooltip is closed");
yield waitForTick();
});
}
function* testESC(swatch, inspector, testActor) {
info("Press escape");

View File

@ -177,9 +177,12 @@ class SwatchColorPickerTooltip extends SwatchBasedEditorTooltip {
// cancelling picker(if it is already selected) on opening eye-dropper
toolbox.highlighterUtils.cancelPicker();
inspector.pickColorFromPage(toolbox, {copyOnSelect: false}).then(() => {
this.eyedropperOpen = true;
// pickColorFromPage will focus the content document. If the devtools are in a
// separate window, the colorpicker tooltip will be closed before pickColorFromPage
// resolves. Flip the flag early to avoid issues with onTooltipHidden().
this.eyedropperOpen = true;
inspector.pickColorFromPage(toolbox, {copyOnSelect: false}).then(() => {
// close the colorpicker tooltip so that only the eyedropper is open.
this.hide();