Bug 1391994 Part 3: Expand devtools tests to verify interactive style edits work on pages with CSP restrictions. r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D41321

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-11-20 22:50:39 +00:00
Родитель f6f97abc9b
Коммит 566e87fdab
4 изменённых файлов: 50 добавлений и 21 удалений

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

@ -64,6 +64,8 @@ support-files =
doc_short_string.css
doc_xulpage.xhtml
sync.html
sync_with_csp.css
sync_with_csp.html
utf-16.css
!/devtools/client/inspector/shared/test/head.js
!/devtools/client/inspector/test/head.js

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

@ -5,6 +5,7 @@
// 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 {
@ -19,29 +20,33 @@ const expectedText = `
`;
add_task(async function() {
await addTab(TESTCASE_URI);
const { inspector, view } = await openRuleView();
await selectNode("#testid", inspector);
const URIs = [TESTCASE_URI, TESTCASE_URI_WITH_CSP];
info("Focusing a new property name in the rule-view");
const ruleEditor = getRuleViewRuleEditor(view, 1);
const editor = await focusEditableField(view, ruleEditor.closeBrace);
is(
inplaceEditor(ruleEditor.newPropSpan),
editor,
"The new property editor has focus"
);
for (const URI of URIs) {
await addTab(URI);
const { inspector, view } = await openRuleView();
await selectNode("#testid", inspector);
const input = editor.input;
input.value = "/* background-color: yellow; */";
info("Focusing a new property name in the rule-view on " + URI);
const ruleEditor = getRuleViewRuleEditor(view, 1);
const editor = await focusEditableField(view, ruleEditor.closeBrace);
is(
inplaceEditor(ruleEditor.newPropSpan),
editor,
"The new property editor has focus"
);
info("Pressing return to commit and focus the new value field");
const onModifications = view.once("ruleview-changed");
EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow);
await onModifications;
const input = editor.input;
input.value = "/* background-color: yellow; */";
const { ui } = await openStyleEditor();
const sourceEditor = await ui.editors[0].getSourceEditor();
const text = sourceEditor.sourceEditor.getText();
is(text, expectedText, "selector edits are synced");
info("Pressing return to commit and focus the new value field");
const onModifications = view.once("ruleview-changed");
EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow);
await onModifications;
const { ui } = await openStyleEditor();
const sourceEditor = await ui.editors[0].getSourceEditor();
const text = sourceEditor.sourceEditor.getText();
is(text, expectedText, "selector edits are synced");
}
});

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

@ -0,0 +1,10 @@
body {
border-width: 15px;
color: red;
}
#testid {
font-size: 4em;
}

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

@ -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>