forked from mirrors/gecko-dev
Bug 1267015 - ESLint cleanup of devtools/client/styleinspector/shared/test; r=bgrins
MozReview-Commit-ID: GKnRmlqIBxb --HG-- extra : rebase_source : 69109deafb0af8113a31832b604208817a224dbb
This commit is contained in:
parent
b2488b6603
commit
e4149a2ab9
18 changed files with 121 additions and 101 deletions
|
|
@ -84,7 +84,6 @@ devtools/client/framework/**
|
||||||
# devtools/client/inspector/shared/*.js files are eslint-clean, so they aren't
|
# devtools/client/inspector/shared/*.js files are eslint-clean, so they aren't
|
||||||
# included in the ignore list.
|
# included in the ignore list.
|
||||||
devtools/client/inspector/fonts/**
|
devtools/client/inspector/fonts/**
|
||||||
devtools/client/inspector/shared/test/**
|
|
||||||
devtools/client/inspector/test/**
|
devtools/client/inspector/test/**
|
||||||
devtools/client/inspector/*.js
|
devtools/client/inspector/*.js
|
||||||
!devtools/client/inspector/breadcrumbs.js
|
!devtools/client/inspector/breadcrumbs.js
|
||||||
|
|
|
||||||
|
|
@ -11,28 +11,25 @@ const TEST_DATA_URI = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQA
|
||||||
// Invalid URL still needs to be reachable otherwise getImageDataUrl will
|
// Invalid URL still needs to be reachable otherwise getImageDataUrl will
|
||||||
// timeout. DevTools chrome:// URLs aren't content accessible, so use some
|
// timeout. DevTools chrome:// URLs aren't content accessible, so use some
|
||||||
// random resource:// URL here.
|
// random resource:// URL here.
|
||||||
const INVALID_IMAGE_URI =
|
const INVALID_IMAGE_URI = "resource://devtools/client/definitions.js";
|
||||||
"resource://devtools/client/definitions.js";
|
|
||||||
|
|
||||||
const ERROR_MESSAGE = Services.strings
|
const ERROR_MESSAGE = Services.strings
|
||||||
.createBundle(PROPERTIES_URL)
|
.createBundle(PROPERTIES_URL)
|
||||||
.GetStringFromName("styleinspector.copyImageDataUrlError");
|
.GetStringFromName("styleinspector.copyImageDataUrlError");
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
const PAGE_CONTENT = [
|
const TEST_URI = `<style type="text/css">
|
||||||
"<style type=\"text/css\">",
|
.valid-background {
|
||||||
" .valid-background {",
|
background-image: url(${TEST_DATA_URI});
|
||||||
" background-image: url(" + TEST_DATA_URI + ");",
|
}
|
||||||
" }",
|
.invalid-background {
|
||||||
" .invalid-background {",
|
background-image: url(${INVALID_IMAGE_URI});
|
||||||
" background-image: url(" + INVALID_IMAGE_URI + ");",
|
}
|
||||||
" }",
|
</style>
|
||||||
"</style>",
|
<div class="valid-background">Valid background image</div>
|
||||||
"<div class=\"valid-background\">Valid background image</div>",
|
<div class="invalid-background">Invalid background image</div>`;
|
||||||
"<div class=\"invalid-background\">Invalid background image</div>"
|
|
||||||
].join("\n");
|
|
||||||
|
|
||||||
yield addTab("data:text/html;charset=utf8," + encodeURIComponent(PAGE_CONTENT));
|
yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_URI));
|
||||||
|
|
||||||
yield startTest();
|
yield startTest();
|
||||||
});
|
});
|
||||||
|
|
@ -42,28 +39,39 @@ function* startTest() {
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
|
|
||||||
info("Test valid background image URL in rule view");
|
info("Test valid background image URL in rule view");
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".valid-background", TEST_DATA_URI);
|
yield testCopyUrlToClipboard({view, inspector}, "data-uri",
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".valid-background", TEST_DATA_URI);
|
".valid-background", TEST_DATA_URI);
|
||||||
|
yield testCopyUrlToClipboard({view, inspector}, "url",
|
||||||
|
".valid-background", TEST_DATA_URI);
|
||||||
|
|
||||||
info("Test invalid background image URL in rue view");
|
info("Test invalid background image URL in rue view");
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".invalid-background", ERROR_MESSAGE);
|
yield testCopyUrlToClipboard({view, inspector}, "data-uri",
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".invalid-background", INVALID_IMAGE_URI);
|
".invalid-background", ERROR_MESSAGE);
|
||||||
|
yield testCopyUrlToClipboard({view, inspector}, "url",
|
||||||
|
".invalid-background", INVALID_IMAGE_URI);
|
||||||
|
|
||||||
info("Opening computed view");
|
info("Opening computed view");
|
||||||
view = selectComputedView(inspector);
|
view = selectComputedView(inspector);
|
||||||
|
|
||||||
info("Test valid background image URL in computed view");
|
info("Test valid background image URL in computed view");
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".valid-background", TEST_DATA_URI);
|
yield testCopyUrlToClipboard({view, inspector}, "data-uri",
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".valid-background", TEST_DATA_URI);
|
".valid-background", TEST_DATA_URI);
|
||||||
|
yield testCopyUrlToClipboard({view, inspector}, "url",
|
||||||
|
".valid-background", TEST_DATA_URI);
|
||||||
|
|
||||||
info("Test invalid background image URL in computed view");
|
info("Test invalid background image URL in computed view");
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".invalid-background", ERROR_MESSAGE);
|
yield testCopyUrlToClipboard({view, inspector}, "data-uri",
|
||||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".invalid-background", INVALID_IMAGE_URI);
|
".invalid-background", ERROR_MESSAGE);
|
||||||
|
yield testCopyUrlToClipboard({view, inspector}, "url",
|
||||||
|
".invalid-background", INVALID_IMAGE_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* testCopyUrlToClipboard({view, inspector}, type, selector, expected) {
|
function* testCopyUrlToClipboard({view, inspector}, type, selector, expected) {
|
||||||
info("Select node in inspector panel");
|
info("Select node in inspector panel");
|
||||||
yield selectNode(selector, inspector);
|
yield selectNode(selector, inspector);
|
||||||
|
|
||||||
info("Retrieve background-image link for selected node in current styleinspector view");
|
info("Retrieve background-image link for selected node in current " +
|
||||||
|
"styleinspector view");
|
||||||
let property = getBackgroundImageProperty(view, selector);
|
let property = getBackgroundImageProperty(view, selector);
|
||||||
let imageLink = property.valueSpan.querySelector(".theme-link");
|
let imageLink = property.valueSpan.querySelector(".theme-link");
|
||||||
ok(imageLink, "Background-image link element found");
|
ok(imageLink, "Background-image link element found");
|
||||||
|
|
@ -71,26 +79,36 @@ function* testCopyUrlToClipboard({view, inspector}, type, selector, expected) {
|
||||||
info("Simulate right click on the background-image URL");
|
info("Simulate right click on the background-image URL");
|
||||||
let popup = once(view._contextmenu._menupopup, "popupshown");
|
let popup = once(view._contextmenu._menupopup, "popupshown");
|
||||||
|
|
||||||
// Cannot rely on synthesizeMouseAtCenter here. The image URL can be displayed on several lines.
|
// Cannot rely on synthesizeMouseAtCenter here. The image URL can be displayed
|
||||||
// A click simulated at the exact center may click between the lines and miss the target
|
// on several lines. A click simulated at the exact center may click between
|
||||||
// Instead, using the top-left corner of first client rect, with an offset of 2 pixels.
|
// the lines and miss the target. Instead, using the top-left corner of first
|
||||||
|
// client rect, with an offset of 2 pixels.
|
||||||
let rect = imageLink.getClientRects()[0];
|
let rect = imageLink.getClientRects()[0];
|
||||||
let x = rect.left + 2;
|
let x = rect.left + 2;
|
||||||
let y = rect.top + 2;
|
let y = rect.top + 2;
|
||||||
|
|
||||||
EventUtils.synthesizeMouseAtPoint(x, y, {button: 2, type: "contextmenu"}, getViewWindow(view));
|
EventUtils.synthesizeMouseAtPoint(x, y, {
|
||||||
|
button: 2,
|
||||||
|
type: "contextmenu"
|
||||||
|
}, getViewWindow(view));
|
||||||
yield popup;
|
yield popup;
|
||||||
|
|
||||||
info("Context menu is displayed");
|
info("Context menu is displayed");
|
||||||
ok(!view._contextmenu.menuitemCopyUrl.hidden, "\"Copy URL\" menu entry is displayed");
|
ok(!view._contextmenu.menuitemCopyUrl.hidden,
|
||||||
ok(!view._contextmenu.menuitemCopyImageDataUrl.hidden, "\"Copy Image Data-URL\" menu entry is displayed");
|
"\"Copy URL\" menu entry is displayed");
|
||||||
|
ok(!view._contextmenu.menuitemCopyImageDataUrl.hidden,
|
||||||
|
"\"Copy Image Data-URL\" menu entry is displayed");
|
||||||
|
|
||||||
if (type == "data-uri") {
|
if (type == "data-uri") {
|
||||||
info("Click Copy Data URI and wait for clipboard");
|
info("Click Copy Data URI and wait for clipboard");
|
||||||
yield waitForClipboard(() => view._contextmenu.menuitemCopyImageDataUrl.click(), expected);
|
yield waitForClipboard(() => {
|
||||||
|
return view._contextmenu.menuitemCopyImageDataUrl.click();
|
||||||
|
}, expected);
|
||||||
} else {
|
} else {
|
||||||
info("Click Copy URL and wait for clipboard");
|
info("Click Copy URL and wait for clipboard");
|
||||||
yield waitForClipboard(() => view._contextmenu.menuitemCopyUrl.click(), expected);
|
yield waitForClipboard(() => {
|
||||||
|
return view._contextmenu.menuitemCopyUrl.click();
|
||||||
|
}, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
info("Hide context menu");
|
info("Hide context menu");
|
||||||
|
|
@ -101,9 +119,8 @@ function getBackgroundImageProperty(view, selector) {
|
||||||
let isRuleView = view instanceof CssRuleView;
|
let isRuleView = view instanceof CssRuleView;
|
||||||
if (isRuleView) {
|
if (isRuleView) {
|
||||||
return getRuleViewProperty(view, selector, "background-image");
|
return getRuleViewProperty(view, selector, "background-image");
|
||||||
} else {
|
|
||||||
return getComputedViewProperty(view, "background-image");
|
|
||||||
}
|
}
|
||||||
|
return getComputedViewProperty(view, "background-image");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
|
||||||
.getService(Ci.nsIScriptSecurityManager);
|
.getService(Ci.nsIScriptSecurityManager);
|
||||||
const XUL_PRINCIPAL = ssm.createCodebasePrincipal(XUL_URI, {});
|
const XUL_PRINCIPAL = ssm.createCodebasePrincipal(XUL_URI, {});
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
requestLongerTimeout(2);
|
requestLongerTimeout(2);
|
||||||
|
|
||||||
info("Checking stylesheets on HTML document");
|
info("Checking stylesheets on HTML document");
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,9 @@ const TEST_DATA = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "background",
|
name: "background",
|
||||||
value: "linear-gradient(to right, rgba(183,222,237,1) 0%, rgba(33,180,226,1) 30%, rgba(31,170,217,.5) 44%, #F06 75%, red 100%)",
|
value: "linear-gradient(to right, rgba(183,222,237,1) 0%, " +
|
||||||
|
"rgba(33,180,226,1) 30%, rgba(31,170,217,.5) 44%, " +
|
||||||
|
"#F06 75%, red 100%)",
|
||||||
test: fragment => {
|
test: fragment => {
|
||||||
is(countAll(fragment), 10);
|
is(countAll(fragment), 10);
|
||||||
let allSwatches = fragment.querySelectorAll("." + COLOR_CLASS);
|
let allSwatches = fragment.querySelectorAll("." + COLOR_CLASS);
|
||||||
|
|
@ -159,7 +161,8 @@ const TEST_DATA = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "background",
|
name: "background",
|
||||||
value: "-moz-radial-gradient(center 45deg, circle closest-side, orange 0%, red 100%)",
|
value: "-moz-radial-gradient(center 45deg, circle closest-side, " +
|
||||||
|
"orange 0%, red 100%)",
|
||||||
test: fragment => {
|
test: fragment => {
|
||||||
is(countAll(fragment), 6);
|
is(countAll(fragment), 6);
|
||||||
let colorSwatches = fragment.querySelectorAll("." + COLOR_CLASS);
|
let colorSwatches = fragment.querySelectorAll("." + COLOR_CLASS);
|
||||||
|
|
@ -207,10 +210,12 @@ const TEST_DATA = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "background-image",
|
name: "background-image",
|
||||||
value: "url(../../../look/at/this/folder/structure/../../red.blue.green.svg )",
|
value: "url(../../../look/at/this/folder/structure/../" +
|
||||||
|
"../red.blue.green.svg )",
|
||||||
test: fragment => {
|
test: fragment => {
|
||||||
is(countAll(fragment), 1);
|
is(countAll(fragment), 1);
|
||||||
is(getUrl(fragment), "../../../look/at/this/folder/structure/../../red.blue.green.svg");
|
is(getUrl(fragment), "../../../look/at/this/folder/structure/../" +
|
||||||
|
"../red.blue.green.svg");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -290,7 +295,7 @@ const TEST_DATA = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
let parser = new OutputParser(document);
|
let parser = new OutputParser(document);
|
||||||
for (let i = 0; i < TEST_DATA.length; i++) {
|
for (let i = 0; i < TEST_DATA.length; i++) {
|
||||||
let data = TEST_DATA[i];
|
let data = TEST_DATA[i];
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const TEST_URI = `
|
||||||
<div id="two" style="color:blue;">two</div>
|
<div id="two" style="color:blue;">two</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ const TEST_URI = `
|
||||||
<div class="test-element">test element</div>
|
<div class="test-element">test element</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
const TEST_URI = "<div class='one'>el 1</div><div class='two'>el 2</div>";
|
const TEST_URI = "<div class='one'>el 1</div><div class='two'>el 2</div>";
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
yield selectNode(".one", inspector);
|
yield selectNode(".one", inspector);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const TEST_URI = `
|
||||||
<div id="testElement">test element</div>
|
<div id="testElement">test element</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
yield selectNode("#testElement", inspector);
|
yield selectNode("#testElement", inspector);
|
||||||
|
|
@ -109,7 +109,7 @@ function* testExpandedComputedViewProperty(computedView, nodeFront) {
|
||||||
|
|
||||||
function getPropertyView(computedView, name) {
|
function getPropertyView(computedView, name) {
|
||||||
let propertyView = null;
|
let propertyView = null;
|
||||||
computedView.propertyViews.some(function(view) {
|
computedView.propertyViews.some(function (view) {
|
||||||
if (view.name == name) {
|
if (view.name == name) {
|
||||||
propertyView = view;
|
propertyView = view;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ const TEST_URI = `
|
||||||
<div id="testElement">test element</div>
|
<div id="testElement">test element</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const TEST_URI = `
|
||||||
<div></div>
|
<div></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
yield selectNode("div", inspector);
|
yield selectNode("div", inspector);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const TEST_URI = `
|
||||||
|
|
||||||
const TYPE = "CssTransformHighlighter";
|
const TYPE = "CssTransformHighlighter";
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const TEST_URI = `
|
||||||
|
|
||||||
var TYPE = "CssTransformHighlighter";
|
var TYPE = "CssTransformHighlighter";
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
let hs = view.highlighters;
|
let hs = view.highlighters;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ const TEST_URI = `
|
||||||
|
|
||||||
const TYPE = "CssTransformHighlighter";
|
const TYPE = "CssTransformHighlighter";
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
|
|
||||||
|
|
@ -34,18 +34,18 @@ add_task(function*() {
|
||||||
isShown: false,
|
isShown: false,
|
||||||
nodeFront: null,
|
nodeFront: null,
|
||||||
nbOfTimesShown: 0,
|
nbOfTimesShown: 0,
|
||||||
show: function(nodeFront) {
|
show: function (nodeFront) {
|
||||||
this.nodeFront = nodeFront;
|
this.nodeFront = nodeFront;
|
||||||
this.isShown = true;
|
this.isShown = true;
|
||||||
this.nbOfTimesShown ++;
|
this.nbOfTimesShown ++;
|
||||||
return promise.resolve(true);
|
return promise.resolve(true);
|
||||||
},
|
},
|
||||||
hide: function() {
|
hide: function () {
|
||||||
this.nodeFront = null;
|
this.nodeFront = null;
|
||||||
this.isShown = false;
|
this.isShown = false;
|
||||||
return promise.resolve();
|
return promise.resolve();
|
||||||
},
|
},
|
||||||
finalize: function() {}
|
finalize: function () {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Inject the mock highlighter in the rule-view
|
// Inject the mock highlighter in the rule-view
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ const TEST_URI = `
|
||||||
|
|
||||||
const TYPE = "CssTransformHighlighter";
|
const TYPE = "CssTransformHighlighter";
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function* () {
|
||||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||||
let {inspector, view} = yield openRuleView();
|
let {inspector, view} = yield openRuleView();
|
||||||
yield selectNode(".test", inspector);
|
yield selectNode(".test", inspector);
|
||||||
|
|
|
||||||
|
|
@ -3,30 +3,26 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>authored sheet test</title>
|
<title>authored sheet test</title>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#target {
|
#target {
|
||||||
color: chartreuse;
|
color: chartreuse;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
|
"use strict";
|
||||||
.getService(SpecialPowers.Ci.nsIIOService)
|
var gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
|
||||||
|
.getService(SpecialPowers.Ci.nsIIOService);
|
||||||
|
|
||||||
var style = "data:text/css,div { background-color: seagreen; }";
|
var style = "data:text/css,div { background-color: seagreen; }";
|
||||||
var uri = gIOService.newURI(style, null, null);
|
var uri = gIOService.newURI(style, null, null);
|
||||||
var windowUtils = SpecialPowers.wrap(window)
|
var windowUtils = SpecialPowers.wrap(window)
|
||||||
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
|
.getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
|
||||||
windowUtils.loadSheet(uri, windowUtils.AUTHOR_SHEET);
|
windowUtils.loadSheet(uri, windowUtils.AUTHOR_SHEET);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="target"> the ocean </div>
|
<div id="target"> the ocean </div>
|
||||||
|
|
||||||
<input type=text placeholder=test></input>
|
<input type=text placeholder=test></input>
|
||||||
<input type=color></input>
|
<input type=color></input>
|
||||||
<input type=range></input>
|
<input type=range></input>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>test</title>
|
<title>test</title>
|
||||||
|
|
||||||
<link href="./doc_content_stylesheet_linked.css" rel="stylesheet" type="text/css">
|
<link href="./doc_content_stylesheet_linked.css" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
/* exported loadCSS */
|
||||||
|
"use strict";
|
||||||
// Load script.css
|
// Load script.css
|
||||||
function loadCSS() {
|
function loadCSS() {
|
||||||
var link = document.createElement('link');
|
let link = document.createElement("link");
|
||||||
link.rel = 'stylesheet';
|
link.rel = "stylesheet";
|
||||||
link.type = 'text/css';
|
link.type = "text/css";
|
||||||
link.href = "./doc_content_stylesheet_script.css";
|
link.href = "./doc_content_stylesheet_script.css";
|
||||||
document.getElementsByTagName('head')[0].appendChild(link);
|
document.getElementsByTagName("head")[0].appendChild(link);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
table {
|
table {
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
/* globals addMessageListener, sendAsyncMessage */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -10,12 +11,12 @@
|
||||||
// then execute code upon receiving, and immediately send back a message.
|
// 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
|
// This is so that chrome test code can execute code in content and wait for a
|
||||||
// response this way:
|
// response this way:
|
||||||
// let response = yield executeInContent(browser, "Test:MessageName", data, true);
|
// let response = yield executeInContent(browser, "Test:MsgName", data, true);
|
||||||
// The response message should have the same name "Test:MessageName"
|
// The response message should have the same name "Test:MsgName"
|
||||||
//
|
//
|
||||||
// Some listeners do not send a response message back.
|
// 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 {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||||
var {CssLogic} = require("devtools/shared/inspector/css-logic");
|
var {CssLogic} = require("devtools/shared/inspector/css-logic");
|
||||||
|
|
@ -30,7 +31,7 @@ var promise = require("promise");
|
||||||
* - {String} name
|
* - {String} name
|
||||||
* @return {String} The value, if found, null otherwise
|
* @return {String} The value, if found, null otherwise
|
||||||
*/
|
*/
|
||||||
addMessageListener("Test:GetRulePropertyValue", function(msg) {
|
addMessageListener("Test:GetRulePropertyValue", function (msg) {
|
||||||
let {name, styleSheetIndex, ruleIndex} = msg.data;
|
let {name, styleSheetIndex, ruleIndex} = msg.data;
|
||||||
let value = null;
|
let value = null;
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ addMessageListener("Test:GetRulePropertyValue", function(msg) {
|
||||||
* @param {Object} objects Expects a 'target' CPOW object
|
* @param {Object} objects Expects a 'target' CPOW object
|
||||||
* @return {Array} A list of stylesheet info objects
|
* @return {Array} A list of stylesheet info objects
|
||||||
*/
|
*/
|
||||||
addMessageListener("Test:GetStyleSheetsInfoForNode", function(msg) {
|
addMessageListener("Test:GetStyleSheetsInfoForNode", function (msg) {
|
||||||
let target = msg.objects.target;
|
let target = msg.objects.target;
|
||||||
let sheets = [];
|
let sheets = [];
|
||||||
|
|
||||||
|
|
@ -82,10 +83,12 @@ addMessageListener("Test:GetStyleSheetsInfoForNode", function(msg) {
|
||||||
* - {String} name: name of the property
|
* - {String} name: name of the property
|
||||||
* @return {String} The value, if found, null otherwise
|
* @return {String} The value, if found, null otherwise
|
||||||
*/
|
*/
|
||||||
addMessageListener("Test:GetComputedStylePropertyValue", function(msg) {
|
addMessageListener("Test:GetComputedStylePropertyValue", function (msg) {
|
||||||
let {selector, pseudo, name} = msg.data;
|
let {selector, pseudo, name} = msg.data;
|
||||||
let element = content.document.querySelector(selector);
|
let doc = content.document;
|
||||||
let value = content.document.defaultView.getComputedStyle(element, pseudo).getPropertyValue(name);
|
|
||||||
|
let element = doc.querySelector(selector);
|
||||||
|
let value = content.getComputedStyle(element, pseudo).getPropertyValue(name);
|
||||||
sendAsyncMessage("Test:GetComputedStylePropertyValue", value);
|
sendAsyncMessage("Test:GetComputedStylePropertyValue", value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -98,7 +101,7 @@ addMessageListener("Test:GetComputedStylePropertyValue", function(msg) {
|
||||||
* - {String} name: name of the property
|
* - {String} name: name of the property
|
||||||
* - {String} expected: the expected value for property
|
* - {String} expected: the expected value for property
|
||||||
*/
|
*/
|
||||||
addMessageListener("Test:WaitForComputedStylePropertyValue", function(msg) {
|
addMessageListener("Test:WaitForComputedStylePropertyValue", function (msg) {
|
||||||
let {selector, pseudo, name, expected} = msg.data;
|
let {selector, pseudo, name, expected} = msg.data;
|
||||||
let element = content.document.querySelector(selector);
|
let element = content.document.querySelector(selector);
|
||||||
waitForSuccess(() => {
|
waitForSuccess(() => {
|
||||||
|
|
@ -108,10 +111,9 @@ addMessageListener("Test:WaitForComputedStylePropertyValue", function(msg) {
|
||||||
return value === expected;
|
return value === expected;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
sendAsyncMessage("Test:WaitForComputedStylePropertyValue");
|
sendAsyncMessage("Test:WaitForComputedStylePropertyValue");
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var dumpn = msg => dump(msg + "\n");
|
var dumpn = msg => dump(msg + "\n");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -125,14 +127,14 @@ var dumpn = msg => dump(msg + "\n");
|
||||||
* @return a promise that resolves when the function returned true or rejects
|
* @return a promise that resolves when the function returned true or rejects
|
||||||
* if the timeout is reached
|
* if the timeout is reached
|
||||||
*/
|
*/
|
||||||
function waitForSuccess(validatorFn, name="untitled") {
|
function waitForSuccess(validatorFn, name = "untitled") {
|
||||||
let def = promise.defer();
|
let def = promise.defer();
|
||||||
|
|
||||||
function wait(validatorFn) {
|
function wait(fn) {
|
||||||
if (validatorFn()) {
|
if (fn()) {
|
||||||
def.resolve();
|
def.resolve();
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => wait(validatorFn), 200);
|
setTimeout(() => wait(fn), 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wait(validatorFn);
|
wait(validatorFn);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
||||||
/* import-globals-from ../../test/head.js */
|
/* import-globals-from ../../test/head.js */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -77,7 +78,7 @@ registerCleanupFunction(() => {
|
||||||
* script, so they can run on remote targets too.
|
* script, so they can run on remote targets too.
|
||||||
*/
|
*/
|
||||||
var _addTab = addTab;
|
var _addTab = addTab;
|
||||||
addTab = function(url) {
|
addTab = function (url) {
|
||||||
return _addTab(url).then(tab => {
|
return _addTab(url).then(tab => {
|
||||||
info("Loading the helper frame script " + FRAME_SCRIPT_URL);
|
info("Loading the helper frame script " + FRAME_SCRIPT_URL);
|
||||||
let browser = tab.linkedBrowser;
|
let browser = tab.linkedBrowser;
|
||||||
|
|
@ -125,7 +126,8 @@ function waitForContentMessage(name) {
|
||||||
* @return {Promise} Resolves to the response data if a response is expected,
|
* @return {Promise} Resolves to the response data if a response is expected,
|
||||||
* immediately resolves otherwise
|
* immediately resolves otherwise
|
||||||
*/
|
*/
|
||||||
function executeInContent(name, data={}, objects={}, expectResponse=true) {
|
function executeInContent(name, data = {}, objects = {},
|
||||||
|
expectResponse = true) {
|
||||||
info("Sending message " + name + " to content");
|
info("Sending message " + name + " to content");
|
||||||
let mm = gBrowser.selectedBrowser.messageManager;
|
let mm = gBrowser.selectedBrowser.messageManager;
|
||||||
|
|
||||||
|
|
@ -184,8 +186,8 @@ function* waitForComputedStyleProperty(selector, pseudo, name, expected) {
|
||||||
*
|
*
|
||||||
* @return a promise that resolves to the inplace-editor element when ready
|
* @return a promise that resolves to the inplace-editor element when ready
|
||||||
*/
|
*/
|
||||||
var focusEditableField = Task.async(function*(ruleView, editable, xOffset=1,
|
var focusEditableField = Task.async(function* (ruleView, editable, xOffset = 1,
|
||||||
yOffset=1, options={}) {
|
yOffset = 1, options = {}) {
|
||||||
let onFocus = once(editable.parentNode, "focus", true);
|
let onFocus = once(editable.parentNode, "focus", true);
|
||||||
info("Clicking on editable field to turn to edit mode");
|
info("Clicking on editable field to turn to edit mode");
|
||||||
EventUtils.synthesizeMouse(editable, xOffset, yOffset, options,
|
EventUtils.synthesizeMouse(editable, xOffset, yOffset, options,
|
||||||
|
|
@ -211,7 +213,7 @@ var focusEditableField = Task.async(function*(ruleView, editable, xOffset=1,
|
||||||
* @return a promise that resolves when the function returned true or rejects
|
* @return a promise that resolves when the function returned true or rejects
|
||||||
* if the timeout is reached
|
* if the timeout is reached
|
||||||
*/
|
*/
|
||||||
function waitForSuccess(validatorFn, name="untitled") {
|
function waitForSuccess(validatorFn, name = "untitled") {
|
||||||
let def = promise.defer();
|
let def = promise.defer();
|
||||||
|
|
||||||
function wait(validator) {
|
function wait(validator) {
|
||||||
|
|
@ -236,7 +238,7 @@ function waitForSuccess(validatorFn, name="untitled") {
|
||||||
* The NodeActor that will used to retrieve the dataURL for the
|
* The NodeActor that will used to retrieve the dataURL for the
|
||||||
* font family tooltip contents.
|
* font family tooltip contents.
|
||||||
*/
|
*/
|
||||||
var getFontFamilyDataURL = Task.async(function*(font, nodeFront) {
|
var getFontFamilyDataURL = Task.async(function* (font, nodeFront) {
|
||||||
let fillStyle = (Services.prefs.getCharPref("devtools.theme") === "light") ?
|
let fillStyle = (Services.prefs.getCharPref("devtools.theme") === "light") ?
|
||||||
"black" : "white";
|
"black" : "white";
|
||||||
|
|
||||||
|
|
@ -372,7 +374,7 @@ function getRuleViewSelectorHighlighterIcon(view, selectorText) {
|
||||||
* - {String} value The expected style value
|
* - {String} value The expected style value
|
||||||
* The style will be checked like so: getComputedStyle(element)[name] === value
|
* The style will be checked like so: getComputedStyle(element)[name] === value
|
||||||
*/
|
*/
|
||||||
var simulateColorPickerChange = Task.async(function*(ruleView, colorPicker,
|
var simulateColorPickerChange = Task.async(function* (ruleView, colorPicker,
|
||||||
newRgba, expectedChange) {
|
newRgba, expectedChange) {
|
||||||
let onRuleViewChanged = ruleView.once("ruleview-changed");
|
let onRuleViewChanged = ruleView.once("ruleview-changed");
|
||||||
info("Getting the spectrum colorpicker object");
|
info("Getting the spectrum colorpicker object");
|
||||||
|
|
@ -447,7 +449,7 @@ function getRuleViewRuleEditor(view, childrenIndex, nodeIndex) {
|
||||||
* @return a promise that resolves to the newly created editor when ready and
|
* @return a promise that resolves to the newly created editor when ready and
|
||||||
* focused
|
* focused
|
||||||
*/
|
*/
|
||||||
var focusNewRuleViewProperty = Task.async(function*(ruleEditor) {
|
var focusNewRuleViewProperty = Task.async(function* (ruleEditor) {
|
||||||
info("Clicking on a close ruleEditor brace to start editing a new property");
|
info("Clicking on a close ruleEditor brace to start editing a new property");
|
||||||
ruleEditor.closeBrace.scrollIntoView();
|
ruleEditor.closeBrace.scrollIntoView();
|
||||||
let editor = yield focusEditableField(ruleEditor.ruleView,
|
let editor = yield focusEditableField(ruleEditor.ruleView,
|
||||||
|
|
@ -472,7 +474,7 @@ var focusNewRuleViewProperty = Task.async(function*(ruleEditor) {
|
||||||
* @return a promise that resolves when the new property name has been entered
|
* @return a promise that resolves when the new property name has been entered
|
||||||
* and once the value field is focused
|
* and once the value field is focused
|
||||||
*/
|
*/
|
||||||
var createNewRuleViewProperty = Task.async(function*(ruleEditor, inputValue) {
|
var createNewRuleViewProperty = Task.async(function* (ruleEditor, inputValue) {
|
||||||
info("Creating a new property editor");
|
info("Creating a new property editor");
|
||||||
let editor = yield focusNewRuleViewProperty(ruleEditor);
|
let editor = yield focusNewRuleViewProperty(ruleEditor);
|
||||||
|
|
||||||
|
|
@ -496,7 +498,7 @@ var createNewRuleViewProperty = Task.async(function*(ruleEditor, inputValue) {
|
||||||
* @return a promise that resolves when the rule-view is filtered for the
|
* @return a promise that resolves when the rule-view is filtered for the
|
||||||
* search term
|
* search term
|
||||||
*/
|
*/
|
||||||
var setSearchFilter = Task.async(function*(view, searchValue) {
|
var setSearchFilter = Task.async(function* (view, searchValue) {
|
||||||
info("Setting filter text to \"" + searchValue + "\"");
|
info("Setting filter text to \"" + searchValue + "\"");
|
||||||
let win = view.styleWindow;
|
let win = view.styleWindow;
|
||||||
let searchField = view.searchField;
|
let searchField = view.searchField;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue