Bug 1246677 - 7 - Clean remaining ruleview and tests eslint warnings; r=jdescottes

MozReview-Commit-ID: BcyEv4fUWJZ

--HG--
extra : rebase_source : d589e9df51222df10db1e2095f5018d8c44bcb5a
This commit is contained in:
Patrick Brosset 2016-02-23 17:09:01 +01:00
Родитель 9138ef7551
Коммит a31b063cce
39 изменённых файлов: 288 добавлений и 224 удалений

Просмотреть файл

@ -92,7 +92,6 @@ devtools/client/framework/**
devtools/client/inspector/computed/**
devtools/client/inspector/fonts/**
devtools/client/inspector/markup/test/**
devtools/client/inspector/rules/**
devtools/client/inspector/shared/test/**
devtools/client/inspector/test/**
devtools/client/inspector/*.js

Просмотреть файл

@ -957,7 +957,7 @@ CssRuleView.prototype = {
let elementStyle = this._elementStyle;
return this._elementStyle.populate().then(() => {
if (this._elementStyle !== elementStyle || this.isDestroyed) {
return;
return null;
}
this._clearRules();
@ -1693,8 +1693,8 @@ RuleViewTool.prototype = {
let target = this.inspector.target;
if (Tools.styleEditor.isTargetSupported(target)) {
gDevTools.showToolbox(target, "styleeditor").then(function(toolbox) {
let sheet = source || href;
toolbox.getCurrentPanel().selectStyleSheet(sheet, line, column);
let url = source || href;
toolbox.getCurrentPanel().selectStyleSheet(url, line, column);
});
}
return;

Просмотреть файл

@ -7,11 +7,11 @@
// Test for as-authored styles.
function* createTestContent(style) {
let content = `<style type="text/css">
let html = `<style type="text/css">
${style}
</style>
<div id="testid" class="testclass">Styled Node</div>`;
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(content));
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(html));
let {inspector, view} = yield openRuleView();
yield selectNode("#testid", inspector);

Просмотреть файл

@ -7,12 +7,12 @@
// Test for as-authored styles.
function* createTestContent(style) {
let content = `<style type="text/css">
let html = `<style type="text/css">
${style}
</style>
<div id="testid" class="testclass">Styled Node</div>`;
let tab = yield addTab("data:text/html;charset=utf-8," +
encodeURIComponent(content));
encodeURIComponent(html));
let {inspector, view} = yield openRuleView();
yield selectNode("#testid", inspector);

Просмотреть файл

@ -7,11 +7,11 @@
// Test for as-authored styles.
function* createTestContent(style) {
let content = `<style type="text/css">
let html = `<style type="text/css">
${style}
</style>
<div id="testid" class="testclass">Styled Node</div>`;
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(content));
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(html));
let {inspector, view} = yield openRuleView();
yield selectNode("#testid", inspector);

Просмотреть файл

@ -20,10 +20,6 @@ const TEST_URI = `
Testing the color picker tooltip!
`;
const PAGE_CONTENT = [
].join("\n");
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {view} = yield openRuleView();

Просмотреть файл

@ -51,7 +51,7 @@ function* testPickingNewColor(view) {
let swatchEl = ruleEl.valueSpan.querySelector(".ruleview-colorswatch");
let colorEl = ruleEl.valueSpan.querySelector(".ruleview-color");
info("Getting the color picker tooltip and clicking on the swatch to show it");
info("Get the color picker tooltip and clicking on the swatch to show it");
let cPicker = view.tooltips.colorPicker;
let onShown = cPicker.tooltip.once("shown");
swatchEl.click();
@ -60,7 +60,8 @@ function* testPickingNewColor(view) {
let change = {
selector: "body",
name: "background-image",
value: "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)"
value: "linear-gradient(to left, rgb(1, 1, 1) 25%, " +
"rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)"
};
yield simulateColorPickerChange(view, cPicker, [1, 1, 1, 1], change);

Просмотреть файл

@ -44,7 +44,8 @@ add_task(function*() {
info("Moving mouse over color picker without any buttons pressed.");
EventUtils.synthesizeMouse(spectrum.dragger, 10, 10, {
button: -1, // -1 = no buttons are pressed down
// -1 = no buttons are pressed down
button: -1,
type: "mousemove",
}, spectrum.dragger.ownerDocument.defaultView);
});

Просмотреть файл

@ -31,7 +31,7 @@ function* testComputedList(inspector, view) {
ok(!expander.hasAttribute("open"), "margin computed list is closed");
info("Opening the computed list of margin property")
info("Opening the computed list of margin property");
expander.click();
ok(expander.hasAttribute("open"), "margin computed list is open");
@ -45,22 +45,28 @@ function* testComputedList(inspector, view) {
];
is(computed.length, propNames.length, "There should be 4 computed values");
is(computedDom.children.length, propNames.length, "There should be 4 nodes in the DOM");
is(computedDom.children.length, propNames.length,
"There should be 4 nodes in the DOM");
propNames.forEach((propName, i) => {
let propValue = i + "px";
is(computed[i].name, propName, "Computed property #" + i + " has name " + propName);
is(computed[i].value, propValue, "Computed property #" + i + " has value " + propValue);
is(computedDom.getElementsByClassName("ruleview-propertyname")[i].textContent, propName,
"Computed property #" + i + " in DOM has correct name");
is(computedDom.getElementsByClassName("ruleview-propertyvalue")[i].textContent, propValue,
"Computed property #" + i + " in DOM has correct value");
is(computed[i].name, propName,
"Computed property #" + i + " has name " + propName);
is(computed[i].value, propValue,
"Computed property #" + i + " has value " + propValue);
is(computedDom.querySelectorAll(".ruleview-propertyname")[i].textContent,
propName,
"Computed property #" + i + " in DOM has correct name");
is(computedDom.querySelectorAll(".ruleview-propertyvalue")[i].textContent,
propValue,
"Computed property #" + i + " in DOM has correct value");
});
info("Closing the computed list of margin property")
info("Closing the computed list of margin property");
expander.click();
ok(!expander.hasAttribute("open"), "margin computed list is closed");
info("Opening the computed list of margin property")
info("Opening the computed list of margin property");
expander.click();
ok(expander.hasAttribute("open"), "margin computed list is open");
is(computed.length, propNames.length, "Still 4 computed values");

Просмотреть файл

@ -1,19 +1,21 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* globals getTestActorWithoutToolbox */
"use strict";
// Test the rule-view content when the inspector gets opened via the page
// ctx-menu "inspect element"
const CONTENT = '<body style="color:red;">\
<div style="color:blue;">\
<p style="color:green;">\
<span style="color:yellow;">test element</span>\
</p>\
</div>\
</body>';
const CONTENT = `
<body style="color:red;">
<div style="color:blue;">
<p style="color:green;">
<span style="color:yellow;">test element</span>
</p>
</div>
</body>
`;
const STRINGS = Services.strings
.createBundle("chrome://devtools-shared/locale/styleinspector.properties");
@ -53,10 +55,12 @@ function checkRuleViewContent({styleDocument}) {
"The rule's selector is correct");
let propertyNames = [...rule.querySelectorAll(".ruleview-propertyname")];
is(propertyNames.length, 1, "There's only one property name, as expected");
is(propertyNames.length, 1,
"There's only one property name, as expected");
let propertyValues = [...rule.querySelectorAll(".ruleview-propertyvalue")];
is(propertyValues.length, 1, "There's only one property value, as expected");
is(propertyValues.length, 1,
"There's only one property value, as expected");
}
}

Просмотреть файл

@ -16,8 +16,6 @@
"use strict";
const {setBaseCssDocsUrl} = require("devtools/client/shared/widgets/MdnDocsWidget");
/**
* The test document tries to confuse the context menu
* code by having a tag called "padding" and a property

Просмотреть файл

@ -17,7 +17,8 @@
"use strict";
const {setBaseCssDocsUrl} = require("devtools/client/shared/widgets/MdnDocsWidget");
const {setBaseCssDocsUrl} =
require("devtools/client/shared/widgets/MdnDocsWidget");
const PROPERTYNAME = "color";
@ -70,6 +71,8 @@ function* testShowAndHideMdnTooltip(view) {
info("Quick check that the tooltip contents are set");
let cssDocs = view.tooltips.cssDocs;
// FIXME: Remove the comment below when bug 1246896 is fixed.
/* eslint-disable mozilla/no-cpows-in-tests */
let tooltipDocument = cssDocs.tooltip.content.contentDocument;
let h1 = tooltipDocument.getElementById("property-name");
is(h1.textContent, PROPERTYNAME, "The MDN docs tooltip h1 is correct");
@ -80,8 +83,3 @@ function* testShowAndHideMdnTooltip(view) {
yield onHidden;
ok(true, "The MDN docs tooltip was hidden on pressing 'escape'");
}
/**
* Returns the root element for the rule view.
*/
var rootElement = view => (view.element) ? view.element : view.styleDocument;

Просмотреть файл

@ -259,7 +259,7 @@ function* checkCopyStyle(view, node, menuItem, expectedPattern, hidden) {
try {
yield waitForClipboard(() => menuItem.click(),
() => checkClipboardData(expectedPattern));
} catch(e) {
} catch (e) {
failedClipboard(expectedPattern);
}

Просмотреть файл

@ -56,9 +56,11 @@ function* testPressingEnterCommitsChanges(swatch, ruleView) {
EventUtils.sendKey("RETURN", widget.parent.ownerDocument.defaultView);
yield onRuleViewChanged;
is((yield getComputedStyleProperty("body", null, "transition-timing-function")),
expected, "The element's timing-function was kept after RETURN");
ok(getRuleViewProperty(ruleView, "body", "transition").valueSpan.textContent
.indexOf("cubic-bezier(") !== -1,
"The text of the timing-function was kept after RETURN");
let style = yield getComputedStyleProperty("body", null,
"transition-timing-function");
is(style, expected, "The element's timing-function was kept after RETURN");
let ruleViewStyle = getRuleViewProperty(ruleView, "body", "transition")
.valueSpan.textContent.indexOf("cubic-bezier(") !== -1;
ok(ruleViewStyle, "The text of the timing-function was kept after RETURN");
}

Просмотреть файл

@ -51,7 +51,8 @@ function* testMarginIncrements(view) {
5: {down: true, start: "0px", end: "-1px", selectAll: true},
6: {down: true, shift: true, start: "0px", end: "-10px", selectAll: true},
7: {pageUp: true, shift: true, start: "0px", end: "100px", selectAll: true},
8: {pageDown: true, shift: true, start: "0px", end: "-100px", selectAll: true},
8: {pageDown: true, shift: true, start: "0px", end: "-100px",
selectAll: true},
9: {start: "0", end: "1px", selectAll: true},
10: {down: true, start: "0", end: "-1px", selectAll: true},
});
@ -90,7 +91,8 @@ function* testHexIncrements(view) {
3: {start: "#CCCCCC", end: "#CDCCCC", selection: [1, 3]},
4: {shift: true, start: "#CCCCCC", end: "#DCCCCC", selection: [1, 3]},
5: {start: "#FFFFFF", end: "#FFFFFF", selectAll: true},
6: {down: true, shift: true, start: "#000000", end: "#000000", selectAll: true}
6: {down: true, shift: true, start: "#000000", end: "#000000",
selectAll: true}
});
}
@ -102,11 +104,14 @@ function* testRgbIncrements(view) {
yield runIncrementTest(rgbColorPropEditor, view, {
1: {start: "rgb(0,0,0)", end: "rgb(0,1,0)", selection: [6, 7]},
2: {shift: true, start: "rgb(0,0,0)", end: "rgb(0,10,0)", selection: [6, 7]},
2: {shift: true, start: "rgb(0,0,0)", end: "rgb(0,10,0)",
selection: [6, 7]},
3: {start: "rgb(0,255,0)", end: "rgb(0,255,0)", selection: [6, 9]},
4: {shift: true, start: "rgb(0,250,0)", end: "rgb(0,255,0)", selection: [6, 9]},
4: {shift: true, start: "rgb(0,250,0)", end: "rgb(0,255,0)",
selection: [6, 9]},
5: {down: true, start: "rgb(0,0,0)", end: "rgb(0,0,0)", selection: [6, 7]},
6: {down: true, shift: true, start: "rgb(0,5,0)", end: "rgb(0,0,0)", selection: [6, 7]}
6: {down: true, shift: true, start: "rgb(0,5,0)", end: "rgb(0,0,0)",
selection: [6, 7]}
});
}
@ -118,14 +123,21 @@ function* testShorthandIncrements(view) {
yield runIncrementTest(paddingPropEditor, view, {
1: {start: "0px 0px 0px 0px", end: "0px 1px 0px 0px", selection: [4, 7]},
2: {shift: true, start: "0px 0px 0px 0px", end: "0px 10px 0px 0px", selection: [4, 7]},
2: {shift: true, start: "0px 0px 0px 0px", end: "0px 10px 0px 0px",
selection: [4, 7]},
3: {start: "0px 0px 0px 0px", end: "1px 0px 0px 0px", selectAll: true},
4: {shift: true, start: "0px 0px 0px 0px", end: "10px 0px 0px 0px", selectAll: true},
5: {down: true, start: "0px 0px 0px 0px", end: "0px 0px -1px 0px", selection: [8, 11]},
6: {down: true, shift: true, start: "0px 0px 0px 0px", end: "-10px 0px 0px 0px", selectAll: true},
7: {up: true, start: "0.1em .1em 0em 0em", end: "0.1em 1.1em 0em 0em", selection: [6, 9]},
8: {up: true, alt: true, start: "0.1em .9em 0em 0em", end: "0.1em 1em 0em 0em", selection: [6, 9]},
9: {up: true, shift: true, start: "0.2em .2em 0em 0em", end: "0.2em 10.2em 0em 0em", selection: [6, 9]}
4: {shift: true, start: "0px 0px 0px 0px", end: "10px 0px 0px 0px",
selectAll: true},
5: {down: true, start: "0px 0px 0px 0px", end: "0px 0px -1px 0px",
selection: [8, 11]},
6: {down: true, shift: true, start: "0px 0px 0px 0px",
end: "-10px 0px 0px 0px", selectAll: true},
7: {up: true, start: "0.1em .1em 0em 0em", end: "0.1em 1.1em 0em 0em",
selection: [6, 9]},
8: {up: true, alt: true, start: "0.1em .9em 0em 0em",
end: "0.1em 1em 0em 0em", selection: [6, 9]},
9: {up: true, shift: true, start: "0.2em .2em 0em 0em",
end: "0.2em 10.2em 0em 0em", selection: [6, 9]}
});
}
@ -143,13 +155,19 @@ function* testOddCases(view) {
5: {start: "'a=-1'", end: "'a=0'", selection: [4, 4]},
6: {start: "0 -1px", end: "0 0px", selection: [2, 2]},
7: {start: "url(-1)", end: "url(-1)", selection: [4, 4]},
8: {start: "url('test1.1.png')", end: "url('test1.2.png')", selection: [11, 11]},
8: {start: "url('test1.1.png')", end: "url('test1.2.png')",
selection: [11, 11]},
9: {start: "url('test1.png')", end: "url('test2.png')", selection: [9, 9]},
10: {shift: true, start: "url('test1.1.png')", end: "url('test11.1.png')", selection: [9, 9]},
11: {down: true, start: "url('test-1.png')", end: "url('test-2.png')", selection: [9, 11]},
12: {start: "url('test1.1.png')", end: "url('test1.2.png')", selection: [11, 12]},
13: {down: true, alt: true, start: "url('test-0.png')", end: "url('test--0.1.png')", selection: [10, 11]},
14: {alt: true, start: "url('test--0.1.png')", end: "url('test-0.png')", selection: [10, 14]},
10: {shift: true, start: "url('test1.1.png')", end: "url('test11.1.png')",
selection: [9, 9]},
11: {down: true, start: "url('test-1.png')", end: "url('test-2.png')",
selection: [9, 11]},
12: {start: "url('test1.1.png')", end: "url('test1.2.png')",
selection: [11, 12]},
13: {down: true, alt: true, start: "url('test-0.png')",
end: "url('test--0.1.png')", selection: [10, 11]},
14: {alt: true, start: "url('test--0.1.png')", end: "url('test-0.png')",
selection: [10, 14]}
});
}
@ -216,9 +234,15 @@ function* testIncrement(editor, options, view) {
let onRuleViewChanged = view.once("ruleview-changed");
let onKeyUp = once(input, "keyup");
let key;
key = options.down ? "VK_DOWN" : "VK_UP";
key = options.pageDown ? "VK_PAGE_DOWN" : options.pageUp ? "VK_PAGE_UP" : key;
if (options.pageDown) {
key = "VK_PAGE_DOWN";
} else if (options.pageUp) {
key = "VK_PAGE_UP";
}
EventUtils.synthesizeKey(key, {altKey: options.alt, shiftKey: options.shift},
view.styleWindow);
yield onKeyUp;

Просмотреть файл

@ -29,7 +29,7 @@ add_task(function*() {
yield testEditableFieldFocus(inspector, view, "VK_TAB", { shiftKey: true });
});
function* testEditableFieldFocus(inspector, view, commitKey, options={}) {
function* testEditableFieldFocus(inspector, view, commitKey, options = {}) {
let ruleEditor = getRuleViewRuleEditor(view, 2);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
is(inplaceEditor(ruleEditor.selectorText), editor,

Просмотреть файл

@ -10,8 +10,6 @@ Services.telemetry.canRecordExtended = true;
registerCleanupFunction(function() {
Services.telemetry.canRecordExtended = oldCanRecord;
});
const HISTOGRAM_ID = "DEVTOOLS_PICKER_EYEDROPPER_OPENED_COUNT";
const FLAG_HISTOGRAM_ID = "DEVTOOLS_PICKER_EYEDROPPER_OPENED_PER_USER_FLAG";
const EXPECTED_TELEMETRY = {
"DEVTOOLS_PICKER_EYEDROPPER_OPENED_COUNT": 2,
"DEVTOOLS_PICKER_EYEDROPPER_OPENED_PER_USER_FLAG": 1
@ -40,8 +38,10 @@ const TEST_URI = `
<body><div id="div1"></div><div id="div2"></div></body>
`;
const ORIGINAL_COLOR = "rgb(255, 0, 153)"; // #f09
const EXPECTED_COLOR = "rgb(255, 255, 85)"; // #ff5
// #f09
const ORIGINAL_COLOR = "rgb(255, 0, 153)";
// #ff5
const EXPECTED_COLOR = "rgb(255, 255, 85)";
// Test opening the eyedropper from the color picker. Pressing escape
// to close it, and clicking the page to select a color.
@ -147,7 +147,7 @@ function openEyedropper(view, swatch) {
return deferred.promise;
}
function inspectPage(dropper, click=true) {
function inspectPage(dropper, click = true) {
let target = document.documentElement;
let win = window;

Просмотреть файл

@ -7,8 +7,6 @@
// Check that inherited properties appear for a nested element in the
// rule view.
var {ELEMENT_STYLE} = require("devtools/server/actors/styles");
const TEST_URI = `
<style type="text/css">
#test2 {

Просмотреть файл

@ -7,8 +7,6 @@
// Check that no inherited properties appear when the property does not apply
// to the nested element.
var {ELEMENT_STYLE} = require("devtools/server/actors/styles");
const TEST_URI = `
<style type="text/css">
#test2 {

Просмотреть файл

@ -26,8 +26,8 @@ add_task(function*() {
});
function* testTopLeft(inspector, view) {
let selector = "#topleft";
let rules = yield assertPseudoElementRulesNumbers(selector,
let id = "#topleft";
let rules = yield assertPseudoElementRulesNumbers(id,
inspector, view, {
elementRulesNb: 4,
firstLineRulesNb: 2,
@ -62,9 +62,10 @@ function* testTopLeft(inspector, view) {
let elementRuleView = getRuleViewRuleEditor(view, 3);
let elementFirstLineRule = rules.firstLineRules[0];
let elementFirstLineRuleView = [...view.element.children[1].children].filter(e => {
return e._ruleEditor && e._ruleEditor.rule === elementFirstLineRule;
})[0]._ruleEditor;
let elementFirstLineRuleView =
[...view.element.children[1].children].filter(e => {
return e._ruleEditor && e._ruleEditor.rule === elementFirstLineRule;
})[0]._ruleEditor;
is(convertTextPropsToString(elementFirstLineRule.textProps),
"color: orange",
@ -84,35 +85,36 @@ function* testTopLeft(inspector, view) {
yield elementFirstLineRule._applyingModifications;
is((yield getComputedStyleProperty(selector, ":first-line", "background-color")),
is((yield getComputedStyleProperty(id, ":first-line", "background-color")),
"rgb(0, 255, 0)", "Added property should have been used.");
is((yield getComputedStyleProperty(selector, ":first-line", "font-style")),
is((yield getComputedStyleProperty(id, ":first-line", "font-style")),
"italic", "Added property should have been used.");
is((yield getComputedStyleProperty(selector, null, "text-decoration")),
is((yield getComputedStyleProperty(id, null, "text-decoration")),
"none", "Added property should not apply to element");
firstProp.setEnabled(false);
yield elementFirstLineRule._applyingModifications;
is((yield getComputedStyleProperty(selector, ":first-line", "background-color")),
is((yield getComputedStyleProperty(id, ":first-line", "background-color")),
"rgb(255, 0, 0)", "Disabled property should now have been used.");
is((yield getComputedStyleProperty(selector, null, "background-color")),
is((yield getComputedStyleProperty(id, null, "background-color")),
"rgb(221, 221, 221)", "Added property should not apply to element");
firstProp.setEnabled(true);
yield elementFirstLineRule._applyingModifications;
is((yield getComputedStyleProperty(selector, ":first-line", "background-color")),
is((yield getComputedStyleProperty(id, ":first-line", "background-color")),
"rgb(0, 255, 0)", "Added property should have been used.");
is((yield getComputedStyleProperty(selector, null, "text-decoration")),
is((yield getComputedStyleProperty(id, null, "text-decoration")),
"none", "Added property should not apply to element");
firstProp = elementRuleView.addProperty("background-color", "rgb(0, 0, 255)", "");
firstProp = elementRuleView.addProperty("background-color",
"rgb(0, 0, 255)", "");
yield elementRule._applyingModifications;
is((yield getComputedStyleProperty(selector, null, "background-color")),
is((yield getComputedStyleProperty(id, null, "background-color")),
"rgb(0, 0, 255)", "Added property should have been used.");
is((yield getComputedStyleProperty(selector, ":first-line", "background-color")),
is((yield getComputedStyleProperty(id, ":first-line", "background-color")),
"rgb(0, 255, 0)", "Added prop does not apply to pseudo");
}
@ -155,12 +157,13 @@ function* testBottomLeft(inspector, view) {
}
function* testParagraph(inspector, view) {
let rules = yield assertPseudoElementRulesNumbers("#bottomleft p", inspector, view, {
elementRulesNb: 3,
firstLineRulesNb: 1,
firstLetterRulesNb: 1,
selectionRulesNb: 1
});
let rules =
yield assertPseudoElementRulesNumbers("#bottomleft p", inspector, view, {
elementRulesNb: 3,
firstLineRulesNb: 1,
firstLetterRulesNb: 1,
selectionRulesNb: 1
});
assertGutters(view);

Просмотреть файл

@ -6,14 +6,15 @@
// Test that the rule view does not go blank while selecting a new node.
const TESTCASE_URI = 'data:text/html;charset=utf-8,' +
'<div id="testdiv" style="font-size:10px;">Test div!</div>';
const TESTCASE_URI = "data:text/html;charset=utf-8," +
"<div id=\"testdiv\" style=\"font-size:10px;\">" +
"Test div!</div>";
add_task(function*() {
yield addTab(TESTCASE_URI);
info("Opening the rule view and selecting the test node");
let {toolbox, inspector, view} = yield openRuleView();
let {inspector, view} = yield openRuleView();
let testdiv = yield getNodeFront("#testdiv", inspector);
yield selectNode(testdiv, inspector);

Просмотреть файл

@ -140,14 +140,14 @@ function* changeElementStyle(selector, style, inspector, testActor) {
yield onRefreshed;
}
function validateTextProp(aProp, aEnabled, aName, aValue, aDesc) {
is(aProp.enabled, aEnabled, aDesc + ": enabled.");
is(aProp.name, aName, aDesc + ": name.");
is(aProp.value, aValue, aDesc + ": value.");
function validateTextProp(prop, enabled, name, value, desc) {
is(prop.enabled, enabled, desc + ": enabled.");
is(prop.name, name, desc + ": name.");
is(prop.value, value, desc + ": value.");
is(aProp.editor.enable.hasAttribute("checked"), aEnabled,
aDesc + ": enabled checkbox.");
is(aProp.editor.nameSpan.textContent, aName, aDesc + ": name span.");
is(aProp.editor.valueSpan.textContent,
aValue, aDesc + ": value span.");
is(prop.editor.enable.hasAttribute("checked"), enabled,
desc + ": enabled checkbox.");
is(prop.editor.nameSpan.textContent, name, desc + ": name span.");
is(prop.editor.valueSpan.textContent,
value, desc + ": value span.");
}

Просмотреть файл

@ -21,7 +21,8 @@ const TEST_URI = `
const TEST_DATA = [
{
desc: "Tests that the search filter works properly in the computed list for property names",
desc: "Tests that the search filter works properly in the computed list " +
"for property names",
search: "margin",
isExpanderOpen: false,
isFilterOpen: false,
@ -32,7 +33,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: true
},
{
desc: "Tests that the search filter works properly in the computed list for property values",
desc: "Tests that the search filter works properly in the computed list " +
"for property values",
search: "0px",
isExpanderOpen: false,
isFilterOpen: false,
@ -43,7 +45,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: true
},
{
desc: "Tests that the search filter works properly in the computed list for property line input",
desc: "Tests that the search filter works properly in the computed list " +
"for property line input",
search: "margin-top:4px",
isExpanderOpen: true,
isFilterOpen: true,
@ -54,7 +57,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: false
},
{
desc: "Tests that the search filter works properly in the computed list for parsed name",
desc: "Tests that the search filter works properly in the computed list " +
"for parsed name",
search: "margin-top:",
isExpanderOpen: true,
isFilterOpen: true,
@ -65,7 +69,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: false
},
{
desc: "Tests that the search filter works properly in the computed list for parsed property value",
desc: "Tests that the search filter works properly in the computed list " +
"for parsed property value",
search: ":4px",
isExpanderOpen: false,
isFilterOpen: false,

Просмотреть файл

@ -32,11 +32,13 @@ const TEST_DATA = [
search: "background-color:#00F"
},
{
desc: "Tests that the search filter works properly for parsed property names",
desc: "Tests that the search filter works properly for parsed property " +
"names",
search: "background:"
},
{
desc: "Tests that the search filter works properly for parsed property values",
desc: "Tests that the search filter works properly for parsed property " +
"values",
search: ":00F"
},
];

Просмотреть файл

@ -31,7 +31,7 @@ add_task(function*() {
let ruleEditor = getRuleViewRuleEditor(view, 1);
let rule = ruleEditor.rule;
let propEditor = rule.textProps[1].editor;
let editor = yield focusEditableField(view, propEditor.valueSpan);
yield focusEditableField(view, propEditor.valueSpan);
info("Check that the correct rules are visible");
is(view.element.children.length, 2, "Should have 2 rules.");

Просмотреть файл

@ -20,13 +20,15 @@ const TEST_URI = `
const TEST_DATA = [
{
desc: "Tests that the search filter works properly for a single rule selector",
desc: "Tests that the search filter works properly for a single rule " +
"selector",
search: "#test",
selectorText: "#testid",
index: 0
},
{
desc: "Tests that the search filter works properly for multiple rule selectors",
desc: "Tests that the search filter works properly for multiple rule " +
"selectors",
search: "body",
selectorText: "html, body, div",
index: 2

Просмотреть файл

@ -80,7 +80,7 @@ function* checkCopySelection(view) {
try {
yield waitForClipboard(() => view._contextmenu.menuitemCopy.click(),
() => checkClipboardData(expectedPattern));
} catch(e) {
} catch (e) {
failedClipboard(expectedPattern);
}
@ -118,7 +118,7 @@ function* checkSelectAll(view) {
try {
yield waitForClipboard(() => view._contextmenu.menuitemCopy.click(),
() => checkClipboardData(expectedPattern));
} catch(e) {
} catch (e) {
failedClipboard(expectedPattern);
}

Просмотреть файл

@ -7,8 +7,6 @@
// Tests that the rule view selector text is highlighted correctly according
// to the components of the selector.
const SEARCH = "00F";
const TEST_URI = [
"<style type='text/css'>",
" h1 {}",

Просмотреть файл

@ -21,7 +21,8 @@ const TEST_URI = `
const TEST_DATA = [
{
desc: "Tests that the strict search filter works properly in the computed list for property names",
desc: "Tests that the strict search filter works properly in the " +
"computed list for property names",
search: "`margin-left`",
isExpanderOpen: true,
isFilterOpen: true,
@ -32,7 +33,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: true
},
{
desc: "Tests that the strict search filter works properly in the computed list for property values",
desc: "Tests that the strict search filter works properly in the " +
"computed list for property values",
search: "`0px`",
isExpanderOpen: true,
isFilterOpen: true,
@ -43,7 +45,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: false
},
{
desc: "Tests that the strict search filter works properly in the computed list for parsed property names",
desc: "Tests that the strict search filter works properly in the " +
"computed list for parsed property names",
search: "`margin-left`:",
isExpanderOpen: true,
isFilterOpen: true,
@ -54,7 +57,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: true
},
{
desc: "Tests that the strict search filter works properly in the computed list for parsed property values",
desc: "Tests that the strict search filter works properly in the " +
"computed list for parsed property values",
search: ":`4px`",
isExpanderOpen: true,
isFilterOpen: true,
@ -65,7 +69,8 @@ const TEST_DATA = [
isMarginLeftHighlighted: false
},
{
desc: "Tests that the strict search filter works properly in the computed list for property line input",
desc: "Tests that the strict search filter works properly in the " +
"computed list for property line input",
search: "`margin-top`:`4px`",
isExpanderOpen: true,
isFilterOpen: true,
@ -77,7 +82,8 @@ const TEST_DATA = [
},
{
desc: "Tests that the strict search filter works properly in the " +
"computed list for a parsed strict property name and non-strict property value",
"computed list for a parsed strict property name and non-strict " +
"property value",
search: "`margin-top`:4px",
isExpanderOpen: true,
isFilterOpen: true,
@ -89,7 +95,8 @@ const TEST_DATA = [
},
{
desc: "Tests that the strict search filter works properly in the " +
"computed list for a parsed strict property value and non-strict property name",
"computed list for a parsed strict property value and non-strict " +
"property name",
search: "i:`4px`",
isExpanderOpen: true,
isFilterOpen: true,

Просмотреть файл

@ -23,31 +23,36 @@ const TEST_URI = `
const TEST_DATA = [
{
desc: "Tests that the strict search filter works properly for property names",
desc: "Tests that the strict search filter works properly for property " +
"names",
search: "`color`",
ruleCount: 2,
propertyIndex: 1
},
{
desc: "Tests that the strict search filter works properly for property values",
desc: "Tests that the strict search filter works properly for property " +
"values",
search: "`2%`",
ruleCount: 2,
propertyIndex: 0
},
{
desc: "Tests that the strict search filter works properly for parsed property names",
desc: "Tests that the strict search filter works properly for parsed " +
"property names",
search: "`color`:",
ruleCount: 2,
propertyIndex: 1
},
{
desc: "Tests that the strict search filter works properly for parsed property values",
desc: "Tests that the strict search filter works properly for parsed " +
"property values",
search: ":`2%`",
ruleCount: 2,
propertyIndex: 0
},
{
desc: "Tests that the strict search filter works properly for property line input",
desc: "Tests that the strict search filter works properly for property " +
"line input",
search: "`width`:`2%`",
ruleCount: 2,
propertyIndex: 0

Просмотреть файл

@ -4,16 +4,13 @@
"use strict";
///////////////////
//
// Whitelisting this test.
// FIXME: Whitelisting this test.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
//
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Unknown sheet source");
// Test the links from the rule-view to the styleeditor
const STYLESHEET_URL = "data:text/css,"+encodeURIComponent(
const STYLESHEET_URL = "data:text/css," + encodeURIComponent(
["#first {",
"color: blue",
"}"].join("\n"));
@ -21,38 +18,39 @@ const STYLESHEET_URL = "data:text/css,"+encodeURIComponent(
const EXTERNAL_STYLESHEET_FILE_NAME = "doc_style_editor_link.css";
const EXTERNAL_STYLESHEET_URL = URL_ROOT + EXTERNAL_STYLESHEET_FILE_NAME;
const DOCUMENT_URL = "data:text/html;charset=utf-8,"+encodeURIComponent(
['<html>' +
'<head>' +
'<title>Rule view style editor link test</title>',
'<style type="text/css"> ',
'html { color: #000000; } ',
'div { font-variant: small-caps; color: #000000; } ',
'.nomatches {color: #ff0000;}</style> <div id="first" style="margin: 10em; ',
'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA">',
'</style>',
'<style>',
'div { font-weight: bold; }',
'</style>',
'<link rel="stylesheet" type="text/css" href="'+STYLESHEET_URL+'">',
'<link rel="stylesheet" type="text/css" href="'+EXTERNAL_STYLESHEET_URL+'">',
'</head>',
'<body>',
'<h1>Some header text</h1>',
'<p id="salutation" style="font-size: 12pt">hi.</p>',
'<p id="body" style="font-size: 12pt">I am a test-case. This text exists ',
'solely to provide some things to ',
'<span style="color: yellow" class="highlight">',
'highlight</span> and <span style="font-weight: bold">count</span> ',
'style list-items in the box at right. If you are reading this, ',
'you should go do something else instead. Maybe read a book. Or better ',
'yet, write some test-cases for another bit of code. ',
'<span style="font-style: italic">some text</span></p>',
'<p id="closing">more text</p>',
'<p>even more text</p>',
'</div>',
'</body>',
'</html>'].join("\n"));
const DOCUMENT_URL = "data:text/html;charset=utf-8," + encodeURIComponent(`
<html>
<head>
<title>Rule view style editor link test</title>
<style type="text/css">
html { color: #000000; }
div { font-variant: small-caps; color: #000000; }
.nomatches {color: #ff0000;}</style> <div id="first" style="margin: 10em;
font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA">
</style>
<style>
div { font-weight: bold; }
</style>
<link rel="stylesheet" type="text/css" href="${STYLESHEET_URL}">
<link rel="stylesheet" type="text/css" href="${EXTERNAL_STYLESHEET_URL}">
</head>
<body>
<h1>Some header text</h1>
<p id="salutation" style="font-size: 12pt">hi.</p>
<p id="body" style="font-size: 12pt">I am a test-case. This text exists
solely to provide some things to
<span style="color: yellow" class="highlight">
highlight</span> and <span style="font-weight: bold">count</span>
style list-items in the box at right. If you are reading this,
you should go do something else instead. Maybe read a book. Or better
yet, write some test-cases for another bit of code.
<span style="font-style: italic">some text</span></p>
<p id="closing">more text</p>
<p>even more text</p>
</div>
</body>
</html>
`);
add_task(function*() {
yield addTab(DOCUMENT_URL);

Просмотреть файл

@ -110,17 +110,20 @@ function* userAgentStylesVisible(inspector, view) {
ok(uaRules.length > data.numUARules, "Has UA rules");
}
ok(userRules.some(rule=> rule.matchedSelectors.length === 1),
ok(userRules.some(rule => rule.matchedSelectors.length === 1),
"There is an inline style for element in user styles");
// These tests rely on the "a" selector being the last test in
// TEST_DATA.
ok(uaRules.some(rule=> rule.matchedSelectors.indexOf(":-moz-any-link") !== -1),
"There is a rule for :-moz-any-link");
ok(uaRules.some(rule=> rule.matchedSelectors.indexOf("*|*:link") !== -1),
"There is a rule for *|*:link");
ok(uaRules.some(rule=> rule.matchedSelectors.length === 1),
"Inline styles for ua styles");
ok(uaRules.some(rule => {
return rule.matchedSelectors.indexOf(":-moz-any-link") !== -1;
}), "There is a rule for :-moz-any-link");
ok(uaRules.some(rule => {
return rule.matchedSelectors.indexOf("*|*:link") !== -1;
}), "There is a rule for *|*:link");
ok(uaRules.some(rule => {
return rule.matchedSelectors.length === 1;
}), "Inline styles for ua styles");
}
function* userAgentStylesNotVisible(inspector, view) {
@ -144,11 +147,13 @@ function* compareAppliedStylesWithUI(inspector, view, filter) {
info("Making sure that UI is consistent with pageStyle.getApplied");
let entries = yield inspector.pageStyle.getApplied(
inspector.selection.nodeFront, {
inherited: true,
matchedSelectors: true,
filter: filter
});
inspector.selection.nodeFront,
{
inherited: true,
matchedSelectors: true,
filter: filter
}
);
// We may see multiple entries that map to a given rule; filter the
// duplicates here to match what the UI does.

Просмотреть файл

@ -11,16 +11,16 @@
</style>
<script>
var gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
.getService(SpecialPowers.Ci.nsIIOService)
var style = "data:text/css,a { background-color: seagreen; }";
var uri = gIOService.newURI(style, null, null);
var windowUtils = SpecialPowers.wrap(window)
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
.getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
windowUtils.loadSheet(uri, windowUtils.AUTHOR_SHEET);
"use strict";
var gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
.getService(SpecialPowers.Ci.nsIIOService);
var style = "data:text/css,a { background-color: seagreen; }";
var uri = gIOService.newURI(style, null, null);
var windowUtils = SpecialPowers.wrap(window)
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
.getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
windowUtils.loadSheet(uri, windowUtils.AUTHOR_SHEET);
</script>
</head>

Просмотреть файл

@ -5,13 +5,15 @@
<link href="./doc_content_stylesheet_linked.css" rel="stylesheet" type="text/css">
<script>
/* eslint no-unused-vars: [2, {"vars": "local"}] */
"use strict";
// Load script.css
function loadCSS() {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
let link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = "./doc_content_stylesheet_script.css";
document.getElementsByTagName('head')[0].appendChild(link);
document.getElementsByTagName("head")[0].appendChild(link);
}
</script>

Просмотреть файл

@ -5,6 +5,7 @@
<title>CSSOM test</title>
<script>
"use strict";
window.onload = function() {
let x = document.styleSheets[0];
x.insertRule("div { color: seagreen; }", 1);

Просмотреть файл

@ -1,6 +1,7 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* globals addMessageListener, sendAsyncMessage */
"use strict";
@ -10,12 +11,12 @@
// then execute code upon receiving, and immediately send back a message.
// This is so that chrome test code can execute code in content and wait for a
// response this way:
// let response = yield executeInContent(browser, "Test:MessageName", data, true);
// The response message should have the same name "Test:MessageName"
// let response = yield executeInContent(browser, "Test:msgName", data, true);
// The response message should have the same name "Test:msgName"
//
// Some listeners do not send a response message back.
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {CssLogic} = require("devtools/shared/inspector/css-logic");
@ -85,7 +86,8 @@ addMessageListener("Test:GetStyleSheetsInfoForNode", function(msg) {
addMessageListener("Test:GetComputedStylePropertyValue", function(msg) {
let {selector, pseudo, name} = msg.data;
let element = content.document.querySelector(selector);
let value = content.document.defaultView.getComputedStyle(element, pseudo).getPropertyValue(name);
let value = content.document.defaultView.getComputedStyle(element, pseudo)
.getPropertyValue(name);
sendAsyncMessage("Test:GetComputedStylePropertyValue", value);
});
@ -108,10 +110,9 @@ addMessageListener("Test:WaitForComputedStylePropertyValue", function(msg) {
return value === expected;
}).then(() => {
sendAsyncMessage("Test:WaitForComputedStylePropertyValue");
})
});
});
var dumpn = msg => dump(msg + "\n");
/**
@ -120,19 +121,17 @@ var dumpn = msg => dump(msg + "\n");
* @param {Function} validatorFn A validator function that returns a boolean.
* This is called every few milliseconds to check if the result is true. When
* it is true, the promise resolves.
* @param {String} name Optional name of the test. This is used to generate
* the success and failure messages.
* @return a promise that resolves when the function returned true or rejects
* if the timeout is reached
*/
function waitForSuccess(validatorFn, name="untitled") {
function waitForSuccess(validatorFn) {
let def = promise.defer();
function wait(validatorFn) {
if (validatorFn()) {
function wait(fn) {
if (fn()) {
def.resolve();
} else {
setTimeout(() => wait(validatorFn), 200);
setTimeout(() => wait(fn), 200);
}
}
wait(validatorFn);

Просмотреть файл

@ -1,6 +1,8 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from ../../test/head.js */
"use strict";
// Import the inspector's head.js first (which itself imports shared-head.js).
@ -12,7 +14,6 @@ registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.defaultColorUnit");
});
var {CssLogic} = require("devtools/shared/inspector/css-logic");
var {getInplaceEditorForSpan: inplaceEditor} =
require("devtools/client/shared/inplace-editor");
@ -38,7 +39,7 @@ addTab = function(url) {
browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
return tab;
});
}
};
/**
* Open the toolbox, with the inspector tool visible, and the rule-view
@ -149,7 +150,8 @@ function waitForContentMessage(name) {
* @return {Promise} Resolves to the response data if a response is expected,
* immediately resolves otherwise
*/
function executeInContent(name, data={}, objects={}, expectResponse=true) {
function executeInContent(name, data = {}, objects = {},
expectResponse = true) {
info("Sending message " + name + " to content");
let mm = gBrowser.selectedBrowser.messageManager;
@ -223,8 +225,8 @@ function* waitForComputedStyleProperty(selector, pseudo, name, expected) {
*
* @return a promise that resolves to the inplace-editor element when ready
*/
var focusEditableField = Task.async(function*(ruleView, editable, xOffset=1,
yOffset=1, options={}) {
var focusEditableField = Task.async(function*(ruleView, 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,

Просмотреть файл

@ -2,6 +2,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from ../../framework/test/shared-head.js */
"use strict";
// Load the shared-head file first.

Просмотреть файл

@ -314,7 +314,7 @@ module.exports = {
* True or false
*/
getIsHeadFile: function(scope) {
var pathAndFilename = scope.getFilename();
var pathAndFilename = this.cleanUpPath(scope.getFilename());
return /.*[\\/]head(_.+)?\.js$/.test(pathAndFilename);
},
@ -330,7 +330,7 @@ module.exports = {
* True or false
*/
getIsXpcshellTest: function(scope) {
var pathAndFilename = scope.getFilename();
var pathAndFilename = this.cleanUpPath(scope.getFilename());
return /.*[\\/]test_.+\.js$/.test(pathAndFilename);
},
@ -346,7 +346,7 @@ module.exports = {
* True or false
*/
getIsBrowserMochitest: function(scope) {
var pathAndFilename = scope.getFilename();
var pathAndFilename = this.cleanUpPath(scope.getFilename());
return /.*[\\/]browser_.+\.js$/.test(pathAndFilename);
},
@ -362,8 +362,6 @@ module.exports = {
* True or false
*/
getIsTest: function(scope) {
var pathAndFilename = scope.getFilename();
if (this.getIsXpcshellTest(scope)) {
return true;
}
@ -405,7 +403,7 @@ module.exports = {
* @return {String} The absolute path
*/
getAbsoluteFilePath: function(context) {
var fileName = context.getFilename();
var fileName = this.cleanUpPath(context.getFilename());
var cwd = process.cwd();
if (path.isAbsolute(fileName)) {
@ -420,5 +418,14 @@ module.exports = {
var dirName = path.dirname(fileName);
return cwd.slice(0, cwd.length - dirName.length) + fileName;
}
},
/**
* When ESLint is run from SublimeText, paths retrieved from
* context.getFileName contain leading and trailing double-quote characters.
* These characters need to be removed.
*/
cleanUpPath: function(path) {
return path.replace(/^"/, "").replace(/"$/, "");
}
};