Bug 1391994 Part 4: Expand devtools tests to verify interactive style edits work on pages with CSP restrictions.
MozReview-Commit-ID: Tpuj5Dlk4v
--- a/devtools/client/styleeditor/test/browser.ini
+++ b/devtools/client/styleeditor/test/browser.ini
@@ -50,16 +50,18 @@ support-files =
sourcemaps-watching.html
test_private.css
test_private.html
doc_long.css
doc_uncached.css
doc_uncached.html
doc_xulpage.xul
sync.html
+ sync_with_csp.css
+ sync_with_csp.html
utf-16.css
!/devtools/client/commandline/test/helpers.js
!/devtools/client/framework/test/shared-head.js
!/devtools/client/inspector/shared/test/head.js
!/devtools/client/inspector/test/head.js
!/devtools/client/inspector/test/shared-head.js
!/devtools/client/responsive.html/test/browser/devices.json
!/devtools/client/shared/test/test-actor-registry.js
--- a/devtools/client/styleeditor/test/browser_styleeditor_syncAddProperty.js
+++ b/devtools/client/styleeditor/test/browser_styleeditor_syncAddProperty.js
@@ -1,45 +1,53 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that adding a new rule is synced to the style editor.
const TESTCASE_URI = TEST_BASE_HTTP + "sync.html";
+const TESTCASE_URI_WITH_CSP = TEST_BASE_HTTP + "sync_with_csp.html";
const expectedText = `
body {
border-width: 15px;
color: red;
}
#testid {
font-size: 4em;
/*! background-color: yellow; */
}
`;
add_task(function* () {
- yield addTab(TESTCASE_URI);
- let { inspector, view } = yield openRuleView();
- yield selectNode("#testid", inspector);
+ let URIs = [
+ TESTCASE_URI,
+ TESTCASE_URI_WITH_CSP,
+ ];
- info("Focusing a new property name in the rule-view");
- let ruleEditor = getRuleViewRuleEditor(view, 1);
- let editor = yield focusEditableField(view, ruleEditor.closeBrace);
- is(inplaceEditor(ruleEditor.newPropSpan), editor,
- "The new property editor has focus");
+ for (let URI of URIs) {
+ yield addTab(URI);
+ let { inspector, view } = yield openRuleView();
+ yield selectNode("#testid", inspector);
- let input = editor.input;
- input.value = "/* background-color: yellow; */";
+ info("Focusing a new property name in the rule-view");
+ let ruleEditor = getRuleViewRuleEditor(view, 1);
+ let editor = yield focusEditableField(view, ruleEditor.closeBrace);
+ is(inplaceEditor(ruleEditor.newPropSpan), editor,
+ "The new property editor has focus");
+
+ let input = editor.input;
+ input.value = "/* background-color: yellow; */";
- info("Pressing return to commit and focus the new value field");
- let onModifications = view.once("ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow);
- yield onModifications;
+ info("Pressing return to commit and focus the new value field");
+ let onModifications = view.once("ruleview-changed");
+ EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow);
+ yield onModifications;
- let { ui } = yield openStyleEditor();
- let sourceEditor = yield ui.editors[0].getSourceEditor();
- let text = sourceEditor.sourceEditor.getText();
- is(text, expectedText, "selector edits are synced");
+ let { ui } = yield openStyleEditor();
+ let sourceEditor = yield ui.editors[0].getSourceEditor();
+ let text = sourceEditor.sourceEditor.getText();
+ is(text, expectedText, "selector edits are synced");
+ }
});
new file mode 100644
--- /dev/null
+++ b/devtools/client/styleeditor/test/sync_with_csp.css
@@ -0,0 +1,10 @@
+
+ body {
+ border-width: 15px;
+ color: red;
+ }
+
+ #testid {
+ font-size: 4em;
+ }
+
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/devtools/client/styleeditor/test/sync_with_csp.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="Content-Security-Policy" content="style-src *">
+ <title>simple testcase with content security policy</title>
+ <link rel="stylesheet" type="text/css" href="sync_with_csp.css" />
+</head>
+<body>
+ <div id="testid">simple testcase with content security policy</div>
+</body>
+</html>