Backed out changeset 08eaa27485c1 (bug 1166774) for linux e10s dt failures

This commit is contained in:
Carsten "Tomcat" Book 2015-06-02 15:52:31 +02:00
parent 2a23ba33bd
commit b460abc8ae
41 changed files with 91 additions and 148 deletions

View File

@ -712,11 +712,7 @@ Rule.prototype = {
let modifications = this.style.startModifyingProperties();
modifications.setProperty(aProperty.name, aValue, aPriority);
modifications.apply().then(() => {
// Ensure dispatching a ruleview-changed event
// also for previews
this.elementStyle._changed();
});
modifications.apply();
},
/**

View File

@ -40,7 +40,7 @@ function* testCancelNew(view) {
let elementRuleEditor = getRuleViewRuleEditor(view, 0);
info("Focusing a new property name in the rule-view");
let editor = yield focusEditableField(view, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused");
info("Bluring the editor input");

View File

@ -33,19 +33,22 @@ add_task(function*() {
let elementRuleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing a new property name in the rule-view");
let editor = yield focusEditableField(view, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused.");
let input = editor.input;
info("Entering a value in the property name editor");
editor.input.value = "color";
let onModifications = elementRuleEditor.rule._applyingModifications;
input.value = "color";
yield onModifications;
info("Pressing return to commit and focus the new value field");
let onValueFocus = once(elementRuleEditor.element, "focus", true);
let onRuleViewChanged = view.once("ruleview-changed");
onModifications = elementRuleEditor.rule._applyingModifications;
EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView);
yield onValueFocus;
yield onRuleViewChanged;
yield onModifications;
// Getting the new value editor after focus
editor = inplaceEditor(view.doc.activeElement);
@ -59,17 +62,17 @@ add_task(function*() {
editor.input.value = "red";
info("Escaping out of the field");
onRuleViewChanged = view.once("ruleview-changed");
onModifications = elementRuleEditor.rule._applyingModifications;
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.doc.defaultView);
yield onRuleViewChanged;
yield onModifications;
info("Checking that the previous field is focused");
let focusedElement = inplaceEditor(elementRuleEditor.rule.textProps[0].editor.valueSpan).input;
is(focusedElement, focusedElement.ownerDocument.activeElement, "Correct element has focus");
onRuleViewChanged = view.once("ruleview-changed");
onModifications = elementRuleEditor.rule._applyingModifications;
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.doc.defaultView);
yield onRuleViewChanged;
yield onModifications;
is(elementRuleEditor.rule.textProps.length, 1, "Removed the new text property.");
is(elementRuleEditor.propertyList.children.length, 1, "Removed the property editor.");

View File

@ -27,7 +27,7 @@ function* testCancelNew(inspector, ruleView) {
// declaration, but leave it empty.
let elementRuleEditor = getRuleViewRuleEditor(ruleView, 0);
let editor = yield focusEditableField(ruleView, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor,
"Property editor is focused");
@ -46,7 +46,7 @@ function* testCancelNewOnEscape(inspector, ruleView) {
// declaration, add some text, then press escape.
let elementRuleEditor = getRuleViewRuleEditor(ruleView, 0);
let editor = yield focusEditableField(ruleView, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "Next focused editor should be the new property editor.");

View File

@ -27,7 +27,7 @@ function* testCreateNew(ruleView) {
let elementRuleEditor = getRuleViewRuleEditor(ruleView, 0);
info("Focusing a new property name in the rule-view");
let editor = yield focusEditableField(ruleView, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor,
"Next focused editor should be the new property editor.");

View File

@ -42,7 +42,7 @@ function* testCreateNew(view) {
let elementRuleEditor = getRuleViewRuleEditor(view, 0);
info("Focusing a new property name in the rule-view");
let editor = yield focusEditableField(view, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused");
let input = editor.input;

View File

@ -29,7 +29,7 @@ add_task(function*() {
function* testCreateNew(inspector, ruleView) {
// Create a new property.
let elementRuleEditor = getRuleViewRuleEditor(ruleView, 0);
let editor = yield focusEditableField(ruleView, elementRuleEditor.closeBrace);
let editor = yield focusEditableField(elementRuleEditor.closeBrace);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor,
"Next focused editor should be the new property editor.");

View File

@ -73,7 +73,8 @@ function* addNewRule(inspector, view, method) {
view.addRuleButton.click();
}
info("Waiting for rule view to change");
yield view.once("ruleview-changed");
let onRuleViewChanged = once(view, "ruleview-changed");
yield onRuleViewChanged;
}
function* testNewRule(view, expected, index) {
@ -89,10 +90,7 @@ function* testNewRule(view, expected, index) {
"Selector text value is as expected: " + expected);
info("Adding new properties to new rule: " + expected)
let onRuleViewChanged = view.once("ruleview-changed");
idRuleEditor.addProperty("font-weight", "bold", "");
yield onRuleViewChanged;
let textProps = idRuleEditor.rule.textProps;
let lastRule = textProps[textProps.length - 1];
is(lastRule.name, "font-weight", "Last rule name is font-weight");

View File

@ -71,7 +71,7 @@ function* testEditSelector(view, name) {
let idRuleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, idRuleEditor.selectorText);
let editor = yield focusEditableField(idRuleEditor.selectorText);
is(inplaceEditor(idRuleEditor.selectorText), editor,
"The selector editor got focused");

View File

@ -39,7 +39,7 @@ function* testImageTooltipAfterColorChange(swatch, url, ruleView) {
let onShown = picker.tooltip.once("shown");
swatch.click();
yield onShown;
yield simulateColorPickerChange(ruleView, picker, [0, 0, 0, 1], {
yield simulateColorPickerChange(picker, [0, 0, 0, 1], {
element: content.document.body,
name: "backgroundImage",
value: 'url("chrome://global/skin/icons/warning-64.png"), linear-gradient(rgb(0, 0, 0), rgb(255, 0, 102) 400px)'

View File

@ -36,7 +36,7 @@ function* testColorChangeIsntRevertedWhenOtherTooltipIsShown(ruleView) {
swatch.click();
yield onShown;
yield simulateColorPickerChange(ruleView, picker, [0, 0, 0, 1], {
yield simulateColorPickerChange(picker, [0, 0, 0, 1], {
element: content.document.body,
name: "backgroundColor",
value: "rgb(0, 0, 0)"

View File

@ -32,7 +32,7 @@ function* testPressingEnterCommitsChanges(swatch, ruleView) {
swatch.click();
yield onShown;
yield simulateColorPickerChange(ruleView, cPicker, [0, 255, 0, .5], {
yield simulateColorPickerChange(cPicker, [0, 255, 0, .5], {
element: content.document.body,
name: "borderLeftColor",
value: "rgba(0, 255, 0, 0.5)"

View File

@ -62,13 +62,13 @@ function* testPickingNewColor(view) {
swatchEl.click();
yield onShown;
yield simulateColorPickerChange(view, cPicker, [1, 1, 1, 1]);
yield simulateColorPickerChange(cPicker, [1, 1, 1, 1]);
is(swatchEl.style.backgroundColor, "rgb(1, 1, 1)",
"The color swatch's background was updated");
is(colorEl.textContent, "#010101", "The color text was updated");
is(content.getComputedStyle(content.document.body).backgroundImage,
"linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)",
"linear-gradient(to left, rgb(255, 0, 102) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)",
"The gradient has been updated correctly");
cPicker.hide();

View File

@ -54,7 +54,7 @@ function* testSimpleMultipleColorChanges(inspector, ruleView) {
{rgba: [200, 200, 200, 1], computed: "rgb(200, 200, 200)"}
];
for (let {rgba, computed} of colors) {
yield simulateColorPickerChange(ruleView, picker, rgba, {
yield simulateColorPickerChange(picker, rgba, {
element: content.document.querySelector("p"),
name: "color",
value: computed
@ -82,7 +82,7 @@ function* testComplexMultipleColorChanges(inspector, ruleView) {
{rgba: [200, 200, 200, 1], computed: "rgb(200, 200, 200)"}
];
for (let {rgba, computed} of colors) {
yield simulateColorPickerChange(ruleView, picker, rgba, {
yield simulateColorPickerChange(picker, rgba, {
element: content.document.body,
name: "backgroundColor",
value: computed
@ -115,7 +115,7 @@ function* testOverriddenMultipleColorChanges(inspector, ruleView) {
{rgba: [200, 200, 200, 1], computed: "rgb(200, 200, 200)"}
];
for (let {rgba, computed} of colors) {
yield simulateColorPickerChange(ruleView, picker, rgba, {
yield simulateColorPickerChange(picker, rgba, {
element: content.document.body,
name: "color",
value: computed

View File

@ -22,11 +22,9 @@ add_task(function*() {
let change = spectrum.once("changed");
info("Pressing mouse down over color picker.");
let onRuleViewChanged = view.once("ruleview-changed");
EventUtils.synthesizeMouseAtCenter(spectrum.dragger, {
type: "mousedown",
}, spectrum.dragger.ownerDocument.defaultView);
yield onRuleViewChanged;
let value = yield change;
info(`Color changed to ${value} on mousedown.`);
@ -43,7 +41,6 @@ add_task(function*() {
// i.e. the buttons that were pressed down between events.
info("Moving mouse over color picker without any buttons pressed.");
EventUtils.synthesizeMouse(spectrum.dragger, 10, 10, {
button: -1, // -1 = no buttons are pressed down
type: "mousemove",

View File

@ -32,7 +32,7 @@ function* testPressingEscapeRevertsChanges(swatch, ruleView) {
swatch.click();
yield onShown;
yield simulateColorPickerChange(ruleView, cPicker, [0, 0, 0, 1], {
yield simulateColorPickerChange(cPicker, [0, 0, 0, 1], {
element: content.document.body,
name: "backgroundColor",
value: "rgb(0, 0, 0)"

View File

@ -66,7 +66,7 @@ add_task(function*() {
info("Focusing the css property editable field");
let propertyName = view.doc.querySelectorAll(".ruleview-propertyname")[0];
let editor = yield focusEditableField(view, propertyName);
let editor = yield focusEditableField(propertyName);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {

View File

@ -48,7 +48,7 @@ add_task(function*() {
info("Focusing the css property editable value");
let value = view.doc.querySelectorAll(".ruleview-propertyvalue")[0];
let editor = yield focusEditableField(view, value);
let editor = yield focusEditableField(value);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {

View File

@ -49,7 +49,7 @@ add_task(function*() {
info("Focusing the css property editable field");
let brace = view.doc.querySelector(".ruleview-ruleclose");
let editor = yield focusEditableField(view, brace);
let editor = yield focusEditableField(brace);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {

View File

@ -51,7 +51,7 @@ add_task(function*() {
info("Focusing a new css property editable property");
let brace = view.doc.querySelectorAll(".ruleview-ruleclose")[1];
let editor = yield focusEditableField(view, brace);
let editor = yield focusEditableField(brace);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {

View File

@ -60,12 +60,10 @@ function* runTestData(view, {value, commitKey, modifiers, expected}) {
let propEditor = idRuleEditor.rule.textProps[0].editor;
info("Focusing the inplace editor field");
let editor = yield focusEditableField(view, propEditor.valueSpan);
let editor = yield focusEditableField(propEditor.valueSpan);
is(inplaceEditor(propEditor.valueSpan), editor, "Focused editor should be the value span.");
info("Entering test data " + value);
let onRuleViewChanged = view.once("ruleview-changed");
EventUtils.sendString(value, view.doc.defaultView);
info("Waiting for focus on the field");
@ -74,13 +72,11 @@ function* runTestData(view, {value, commitKey, modifiers, expected}) {
info("Entering the commit key " + commitKey + " " + modifiers);
EventUtils.synthesizeKey(commitKey, modifiers);
yield onBlur;
// No matter if we escape or commit the change, the preview throttle is going
// to update the property value
yield onRuleViewChanged;
if (commitKey === "VK_ESCAPE") {
is(propEditor.valueSpan.textContent, expected, "Value is as expected: " + expected);
} else {
yield once(view, "ruleview-changed");
is(propEditor.valueSpan.textContent, expected, "Value is as expected: " + expected);
}
}

View File

@ -148,7 +148,7 @@ function* testOddCases(view) {
};
function* runIncrementTest(propertyEditor, view, tests) {
let editor = yield focusEditableField(view, propertyEditor.valueSpan);
let editor = yield focusEditableField(propertyEditor.valueSpan);
for(let test in tests) {
yield testIncrement(editor, tests[test], view, propertyEditor);
@ -167,7 +167,7 @@ function* testIncrement(editor, options, view, {ruleEditor}) {
is(input.value, options.start, "Value initialized at " + options.start);
let onRuleViewChanged = view.once("ruleview-changed");
let onModifications = ruleEditor.rule._applyingModifications;
let onKeyUp = once(input, "keyup");
let key;
key = options.down ? "VK_DOWN" : "VK_UP";
@ -175,10 +175,7 @@ function* testIncrement(editor, options, view, {ruleEditor}) {
EventUtils.synthesizeKey(key, {altKey: options.alt, shiftKey: options.shift},
view.doc.defaultView);
yield onKeyUp;
// Only expect a change if the value actually changed!
if (options.start !== options.end) {
yield onRuleViewChanged;
}
yield onModifications;
is(input.value, options.end, "Value changed to " + options.end);
is(editor.input.value, options.end, "Value changed to " + options.end);
}

View File

@ -52,7 +52,7 @@ function* testEditProperty(ruleEditor, name, value, isValid) {
let propEditor = ruleEditor.rule.textProps[0].editor;
info("Focusing an existing property name in the rule-view");
let editor = yield focusEditableField(ruleEditor.ruleView, propEditor.nameSpan, 32, 1);
let editor = yield focusEditableField(propEditor.nameSpan, 32, 1);
is(inplaceEditor(propEditor.nameSpan), editor, "The property name editor got focused");
let input = editor.input;
@ -90,4 +90,4 @@ function* testEditProperty(ruleEditor, name, value, isValid) {
} else {
isnot(propValue, value, name + " shouldn't have been set.");
}
}
}

View File

@ -34,7 +34,7 @@ function* testEditProperty(inspector, ruleView) {
let idRuleEditor = getRuleViewRuleEditor(ruleView, 1);
let propEditor = idRuleEditor.rule.textProps[0].editor;
let editor = yield focusEditableField(ruleView, propEditor.nameSpan);
let editor = yield focusEditableField(propEditor.nameSpan);
let input = editor.input;
is(inplaceEditor(propEditor.nameSpan), editor, "Next focused editor should be the name editor.");

View File

@ -35,25 +35,26 @@ add_task(function*() {
let doc = ruleEditor.doc;
let propEditor = ruleEditor.rule.textProps[1].editor;
let editor = yield focusEditableField(view, propEditor.valueSpan);
let editor = yield focusEditableField(propEditor.valueSpan);
info("Deleting all the text out of a value field");
yield sendCharsAndWaitForFocus(view, ruleEditor.element, ["VK_DELETE", "VK_RETURN"]);
yield sendCharsAndWaitForFocus(ruleEditor.element, ["VK_DELETE", "VK_RETURN"]);
yield ruleEditor.rule._applyingModifications;
info("Pressing enter a couple times to cycle through editors");
yield sendCharsAndWaitForFocus(view, ruleEditor.element, ["VK_RETURN"]);
yield sendCharsAndWaitForFocus(view, ruleEditor.element, ["VK_RETURN"]);
yield sendCharsAndWaitForFocus(ruleEditor.element, ["VK_RETURN"]);
yield sendCharsAndWaitForFocus(ruleEditor.element, ["VK_RETURN"]);
yield ruleEditor.rule._applyingModifications;
isnot (ruleEditor.rule.textProps[1].editor.nameSpan.style.display, "none", "The name span is visible");
is (ruleEditor.rule.textProps.length, 2, "Correct number of props");
});
function* sendCharsAndWaitForFocus(view, element, chars) {
function* sendCharsAndWaitForFocus(element, chars) {
let onFocus = once(element, "focus", true);
for (let ch of chars) {
let onRuleViewChanged = view.once("ruleview-changed");
EventUtils.sendChar(ch, element.ownerDocument.defaultView);
yield onRuleViewChanged;
}
yield onFocus;
}

View File

@ -68,7 +68,7 @@ function* runTestData(inspector, view, data) {
let idRuleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, idRuleEditor.selectorText);
let editor = yield focusEditableField(idRuleEditor.selectorText);
is(inplaceEditor(idRuleEditor.selectorText), editor,
"The selector editor got focused");

View File

@ -35,7 +35,7 @@ function* testEditSelector(view, name) {
let idRuleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, idRuleEditor.selectorText);
let editor = yield focusEditableField(idRuleEditor.selectorText);
is(inplaceEditor(idRuleEditor.selectorText), editor,
"The selector editor got focused");

View File

@ -50,7 +50,7 @@ function* testEditSelector(view, name) {
getRuleViewRuleEditor(view, 1, 0);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, idRuleEditor.selectorText);
let editor = yield focusEditableField(idRuleEditor.selectorText);
is(inplaceEditor(idRuleEditor.selectorText), editor,
"The selector editor got focused");

View File

@ -29,7 +29,7 @@ function* testEditSelector(view, name) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, ruleEditor.selectorText);
let editor = yield focusEditableField(ruleEditor.selectorText);
is(inplaceEditor(ruleEditor.selectorText), editor,
"The selector editor got focused");

View File

@ -48,7 +48,7 @@ function* testEditSelector(view, name) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, ruleEditor.selectorText);
let editor = yield focusEditableField(ruleEditor.selectorText);
is(inplaceEditor(ruleEditor.selectorText), editor,
"The selector editor got focused");

View File

@ -38,7 +38,7 @@ function* testEditSelector(view, name) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, ruleEditor.selectorText);
let editor = yield focusEditableField(ruleEditor.selectorText);
is(inplaceEditor(ruleEditor.selectorText), editor,
"The selector editor got focused");
@ -70,7 +70,7 @@ function* testAddProperty(view) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
info("Focusing a new property name in the rule-view");
let editor = yield focusEditableField(view, ruleEditor.closeBrace);
let editor = yield focusEditableField(ruleEditor.closeBrace);
is(inplaceEditor(ruleEditor.newPropSpan), editor,
"The new property editor got focused");
@ -81,10 +81,10 @@ function* testAddProperty(view) {
info("Pressing return to commit and focus the new value field");
let onValueFocus = once(ruleEditor.element, "focus", true);
let onRuleViewChanged = view.once("ruleview-changed");
let onModifications = ruleEditor.rule._applyingModifications;
EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView);
yield onValueFocus;
yield onRuleViewChanged;
yield onModifications;
// Getting the new value editor after focus
editor = inplaceEditor(view.doc.activeElement);
@ -98,10 +98,10 @@ function* testAddProperty(view) {
info("Entering a value and bluring the field to expect a rule change");
editor.input.value = "center";
let onBlur = once(editor.input, "blur");
onRuleViewChanged = view.once("ruleview-changed");
onModifications = ruleEditor.rule._applyingModifications;
editor.input.blur();
yield onBlur;
yield onRuleViewChanged;
yield onModifications;
is(textProp.value, "center", "Text prop should have been changed.");
is(textProp.overridden, false, "Property should not be overridden");

View File

@ -72,7 +72,7 @@ add_task(function*() {
ok(dropper, "dropper opened");
yield testSelect(view, swatch, dropper);
yield testSelect(swatch, dropper);
checkTelemetry();
});
@ -92,23 +92,27 @@ function testESC(swatch, dropper) {
return deferred.promise;
}
function* testSelect(view, swatch, dropper) {
let onDestroyed = dropper.once("destroy");
// the change to the content is done async after rule view change
let onRuleViewChanged = view.once("ruleview-changed");
function testSelect(swatch, dropper) {
let deferred = promise.defer();
dropper.once("destroy", () => {
let color = swatch.style.backgroundColor;
is(color, EXPECTED_COLOR, "swatch changed colors");
// the change to the content is done async after rule view change
executeSoon(() => {
let element = content.document.querySelector("div");
is(content.window.getComputedStyle(element).backgroundColor,
EXPECTED_COLOR,
"div's color set to body color after dropper");
deferred.resolve();
});
});
inspectPage(dropper);
yield onDestroyed;
yield onRuleViewChanged;
let color = swatch.style.backgroundColor;
is(color, EXPECTED_COLOR, "swatch changed colors");
let element = content.document.querySelector("div");
is(content.window.getComputedStyle(element).backgroundColor,
EXPECTED_COLOR,
"div's color set to body color after dropper");
return deferred.promise;
}
function clearTelemetry() {

View File

@ -18,12 +18,8 @@ add_task(function*() {
let filterTooltip = view.tooltips.filterEditor;
let onShow = filterTooltip.tooltip.once("shown");
let onRuleViewChanged = view.once("ruleview-changed");
swatch.click();
yield onShow;
// Clicking on swatch runs a preview of the current value
// and updates the rule-view
yield onRuleViewChanged;
ok(true, "The shown event was emitted after clicking on swatch");
ok(!inplaceEditor(swatch.parentNode),

View File

@ -28,12 +28,8 @@ add_task(function*() {
info("Typing ENTER to focus the next field: property value");
onFocus = once(brace.parentNode, "focus", true);
// The rule view changes twice, once for the first field to loose focus
// and a second time for the second field to gain focus
let onRuleViewChanged = view.once("ruleview-changed").then(() => view.once("ruleview-changed"));
EventUtils.sendKey("return");
yield onFocus;
yield onRuleViewChanged;
ok(true, "The value field was focused");
info("Entering a property value");
@ -42,10 +38,8 @@ add_task(function*() {
info("Typing ENTER again should focus a new property name");
onFocus = once(brace.parentNode, "focus", true);
onRuleViewChanged = view.once("ruleview-changed");
EventUtils.sendKey("return");
yield onFocus;
yield onRuleViewChanged;
ok(true, "The new property name field was focused");
getCurrentInplaceEditor(view).input.blur();
});

View File

@ -43,7 +43,7 @@ function* testLivePreviewData(data, ruleView, selector) {
let propEditor = idRuleEditor.rule.textProps[0].editor;
info("Focusing the property value inplace-editor");
let editor = yield focusEditableField(ruleView, propEditor.valueSpan);
let editor = yield focusEditableField(propEditor.valueSpan);
is(inplaceEditor(propEditor.valueSpan), editor, "The focused editor is the value");
info("Enter a value in the editor")

View File

@ -22,35 +22,17 @@ add_task(function*() {
yield testCreateNewMultiUnfinished(inspector, ruleEditor, view);
});
function waitRuleViewChanged(view, n) {
let deferred = promise.defer();
let count = 0;
let listener = function () {
if (++count == n) {
view.off("ruleview-changed", listener);
deferred.resolve();
}
}
view.on("ruleview-changed", listener);
return deferred.promise;
}
function* testCreateNewMultiUnfinished(inspector, ruleEditor, view) {
let onMutation = inspector.once("markupmutation");
// There is 6 rule-view updates, one for the rule view creation,
// one for each new property and one last for throttle update.
let onRuleViewChanged = waitRuleViewChanged(view, 6);
yield createNewRuleViewProperty(ruleEditor,
"color:blue;background : orange ; text-align:center; border-color: ");
yield onMutation;
yield onRuleViewChanged;
is(ruleEditor.rule.textProps.length, 4, "Should have created new text properties.");
is(ruleEditor.propertyList.children.length, 4, "Should have created property editors.");
EventUtils.sendString("red", view.doc.defaultView);
onRuleViewChanged = view.once("ruleview-changed");
EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView);
yield onRuleViewChanged;
is(ruleEditor.rule.textProps.length, 4, "Should have the same number of text properties.");
is(ruleEditor.propertyList.children.length, 5, "Should have added the changed value editor.");

View File

@ -43,7 +43,7 @@ function* modifyRuleViewWidth(value, ruleView, inspector) {
let valueSpan = getStyleRule(ruleView).querySelector(".ruleview-propertyvalue");
info("Focusing the property value to set it to edit mode");
let editor = yield focusEditableField(ruleView, valueSpan.parentNode);
let editor = yield focusEditableField(valueSpan.parentNode);
ok(editor.input, "The inplace-editor field is ready");
info("Setting the new value");

View File

@ -53,7 +53,7 @@ function* testManualEdit(inspector, view) {
let {valueSpan} = getRuleViewProperty(view, "div", "color");
let newColor = "#C9184E"
let editor = yield focusEditableField(view, valueSpan);
let editor = yield focusEditableField(valueSpan);
info("Typing new value");
let input = editor.input;
@ -86,7 +86,7 @@ function* testColorPickerEdit(inspector, view) {
let rgbaColor = [83, 183, 89, 1];
let rgbaColorText = "rgba(83, 183, 89, 1)";
yield simulateColorPickerChange(view, picker, rgbaColor);
yield simulateColorPickerChange(picker, rgbaColor);
is(swatch.parentNode.dataset.color, rgbaColorText, "data-color was updated");
view.doc.popupNode = swatch;

View File

@ -101,7 +101,7 @@ function* testTooltipAppearsEvenInEditMode(view) {
function turnToEditMode(ruleView) {
let brace = ruleView.doc.querySelector(".ruleview-ruleclose");
return focusEditableField(ruleView, brace);
return focusEditableField(brace);
}
function* testComputedView(view) {

View File

@ -81,8 +81,6 @@ function* testPickerDimension(ruleView) {
ok(panelRect.height >= h, "The panel is high enough to show the picker");
let onHidden = cPicker.tooltip.once("hidden");
let onRuleViewChanged = ruleView.once("ruleview-changed");
cPicker.hide();
yield onHidden;
yield onRuleViewChanged;
}

View File

@ -412,31 +412,16 @@ function* waitForComputedStyleProperty(selector, pseudo, name, expected) {
* focus
* @return a promise that resolves to the inplace-editor element when ready
*/
let focusEditableField = Task.async(function*(ruleView, editable, xOffset=1, yOffset=1, options={}) {
// Focusing the name or value input is going to fire a preview and update the rule view
let expectRuleViewUpdate =
editable.classList.contains("ruleview-propertyname") ||
editable.classList.contains("ruleview-propertyvalue");
let onRuleViewChanged;
if (expectRuleViewUpdate) {
onRuleViewChanged = ruleView.once("ruleview-changed");
}
let focusEditableField = Task.async(function*(editable, xOffset=1, yOffset=1, options={}) {
let onFocus = once(editable.parentNode, "focus", true);
info("Clicking on editable field to turn to edit mode");
EventUtils.synthesizeMouse(editable, xOffset, yOffset, options,
editable.ownerDocument.defaultView);
let event = yield onFocus;
info("Editable field gained focus, returning the input field now");
let onEdit = inplaceEditor(editable.ownerDocument.activeElement);
if (expectRuleViewUpdate) {
info("Waiting for rule view update");
yield onRuleViewChanged;
}
return onEdit;
return inplaceEditor(editable.ownerDocument.activeElement);
});
/**
@ -723,7 +708,6 @@ function getRuleViewSelectorHighlighterIcon(view, selectorText) {
/**
* Simulate a color change in a given color picker tooltip, and optionally wait
* for a given element in the page to have its style changed as a result
* @param {RuleView} ruleView The related rule view instance
* @param {SwatchColorPickerTooltip} colorPicker
* @param {Array} newRgba The new color to be set [r, g, b, a]
* @param {Object} expectedChange Optional object that needs the following props:
@ -733,8 +717,7 @@ function getRuleViewSelectorHighlighterIcon(view, selectorText) {
* - {String} value The expected style value
* The style will be checked like so: getComputedStyle(element)[name] === value
*/
let simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, newRgba, expectedChange) {
let onRuleViewChanged = ruleView.once("ruleview-changed");
let simulateColorPickerChange = Task.async(function*(colorPicker, newRgba, expectedChange) {
info("Getting the spectrum colorpicker object");
let spectrum = yield colorPicker.spectrum;
info("Setting the new color");
@ -742,8 +725,6 @@ let simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, newR
info("Applying the change");
spectrum.updateUI();
spectrum.onChange();
info("Waiting for rule-view to update");
yield onRuleViewChanged;
if (expectedChange) {
info("Waiting for the style to be applied on the page");
@ -799,7 +780,7 @@ function getRuleViewRuleEditor(view, childrenIndex, nodeIndex) {
let focusNewRuleViewProperty = Task.async(function*(ruleEditor) {
info("Clicking on a close ruleEditor brace to start editing a new property");
ruleEditor.closeBrace.scrollIntoView();
let editor = yield focusEditableField(ruleEditor.ruleView, ruleEditor.closeBrace);
let editor = yield focusEditableField(ruleEditor.closeBrace);
is(inplaceEditor(ruleEditor.newPropSpan), editor, "Focused editor is the new property editor.");
is(ruleEditor.rule.textProps.length, 0, "Starting with one new text property.");