Bug 1246677 - 5 - Get rid of 'content' in ruleview test files; r=jdescottes

MozReview-Commit-ID: Af07cexjJOv

--HG--
extra : rebase_source : 1d7e8633a964a6d060fdda1a0eb374183a2b5f93
This commit is contained in:
Patrick Brosset 2016-02-22 10:33:04 +01:00
Родитель 0621df70d8
Коммит 26f78191e7
5 изменённых файлов: 68 добавлений и 67 удалений

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

@ -34,7 +34,7 @@ const TEST_DATA = [
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openRuleView();
let {inspector, view, testActor} = yield openRuleView();
for (let data of TEST_DATA) {
let {node, expected} = data;
@ -43,7 +43,8 @@ add_task(function*() {
yield testNewRule(view, expected, 1);
info("Resetting page content");
content.document.body.innerHTML = TEST_URI;
yield testActor.eval(
"content.document.body.innerHTML = `" + TEST_URI + "`;");
}
});

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

@ -34,7 +34,7 @@ const TEST_DATA = [
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openRuleView();
let {inspector, view, testActor} = yield openRuleView();
for (let data of TEST_DATA) {
let {node, expected} = data;
@ -43,7 +43,8 @@ add_task(function*() {
yield testNewRule(view, expected, 1);
info("Resetting page content");
content.document.body.innerHTML = TEST_URI;
yield testActor.eval(
"content.document.body.innerHTML = `" + TEST_URI + "`;");
}
});

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

@ -6,49 +6,46 @@
// Test that the rule-view content is correct
const TEST_URI = `
<style type="text/css">
@media screen and (min-width: 10px) {
#testid {
background-color: blue;
}
}
.testclass, .unmatched {
background-color: green;
}
</style>
<div id="testid" class="testclass">Styled Node</div>
<div id="testid2">Styled Node</div>
`;
add_task(function*() {
yield addTab("data:text/html;charset=utf-8,browser_ruleview_content.js");
let {toolbox, inspector, view} = yield openRuleView();
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openRuleView();
info("Creating the test document");
let style = "" +
"@media screen and (min-width: 10px) {" +
" #testid {" +
" background-color: blue;" +
" }" +
"}" +
".testclass, .unmatched {" +
" background-color: green;" +
"}";
let styleNode = addStyle(content.document, style);
content.document.body.innerHTML = "<div id='testid' class='testclass'>Styled Node</div>" +
"<div id='testid2'>Styled Node</div>";
yield testContentAfterNodeSelection(inspector, view);
});
function* testContentAfterNodeSelection(inspector, ruleView) {
yield selectNode("#testid", inspector);
is(ruleView.element.querySelectorAll("#noResults").length, 0,
is(view.element.querySelectorAll("#noResults").length, 0,
"After a highlight, no longer has a no-results element.");
yield clearCurrentNodeSelection(inspector)
is(ruleView.element.querySelectorAll("#noResults").length, 1,
yield clearCurrentNodeSelection(inspector);
is(view.element.querySelectorAll("#noResults").length, 1,
"After highlighting null, has a no-results element again.");
yield selectNode("#testid", inspector);
let linkText = getRuleViewLinkTextByIndex(ruleView, 1);
is(linkText, "inline:1 @screen and (min-width: 10px)",
let linkText = getRuleViewLinkTextByIndex(view, 1);
is(linkText, "inline:3 @screen and (min-width: 10px)",
"link text at index 1 contains media query text.");
linkText = getRuleViewLinkTextByIndex(ruleView, 2);
is(linkText, "inline:1",
linkText = getRuleViewLinkTextByIndex(view, 2);
is(linkText, "inline:7",
"link text at index 2 contains no media query text.");
let classEditor = getRuleViewRuleEditor(ruleView, 2);
is(classEditor.selectorText.querySelector(".ruleview-selector-matched").textContent,
let selector = getRuleViewRuleEditor(view, 2).selectorText;
is(selector.querySelector(".ruleview-selector-matched").textContent,
".testclass", ".textclass should be matched.");
is(classEditor.selectorText.querySelector(".ruleview-selector-unmatched").textContent,
is(selector.querySelector(".ruleview-selector-unmatched").textContent,
".unmatched", ".unmatched should not be matched.");
}
});

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

@ -7,9 +7,23 @@
// Test that increasing/decreasing values in rule view using
// arrow keys works correctly.
const TEST_URI = `
<style>
#test {
margin-top: 0px;
padding-top: 0px;
color: #000000;
background-color: #000000;
background: none;
transition: initial;
z-index: 0;
}
</style>
<div id="test"></div>
`;
add_task(function*() {
yield addTab("data:text/html;charset=utf-8,sample document for bug 722691");
createDocument();
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openRuleView();
yield selectNode("#test", inspector);
@ -23,22 +37,6 @@ add_task(function*() {
yield testZeroValueIncrements(view);
});
function createDocument() {
content.document.body.innerHTML = "" +
"<style>" +
" #test {" +
" margin-top:0px;" +
" padding-top: 0px;" +
" color:#000000;" +
" background-color: #000000;" +
" background: none;" +
" transition: initial;" +
" z-index: 0;" +
" }" +
"</style>" +
"<div id=\"test\"></div>";
}
function* testMarginIncrements(view) {
info("Testing keyboard increments on the margin property");

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

@ -56,13 +56,13 @@ const DOCUMENT_URL = "data:text/html;charset=utf-8,"+encodeURIComponent(
add_task(function*() {
yield addTab(DOCUMENT_URL);
let {toolbox, inspector, view} = yield openRuleView();
let {toolbox, inspector, view, testActor} = yield openRuleView();
yield selectNode("div", inspector);
yield testInlineStyle(view);
yield testFirstInlineStyleSheet(view, toolbox);
yield testSecondInlineStyleSheet(view, toolbox);
yield testExternalStyleSheet(view, toolbox);
yield testFirstInlineStyleSheet(view, toolbox, testActor);
yield testSecondInlineStyleSheet(view, toolbox, testActor);
yield testExternalStyleSheet(view, toolbox, testActor);
});
function* testInlineStyle(view) {
@ -80,7 +80,7 @@ function* testInlineStyle(view) {
gBrowser.removeTab(tab);
}
function* testFirstInlineStyleSheet(view, toolbox) {
function* testFirstInlineStyleSheet(view, toolbox, testActor) {
info("Testing inline stylesheet");
info("Listening for toolbox switch to the styleeditor");
@ -92,10 +92,10 @@ function* testFirstInlineStyleSheet(view, toolbox) {
ok(true, "Switched to the style-editor panel in the toolbox");
validateStyleEditorSheet(editor, 0);
yield validateStyleEditorSheet(editor, 0, testActor);
}
function* testSecondInlineStyleSheet(view, toolbox) {
function* testSecondInlineStyleSheet(view, toolbox, testActor) {
info("Testing second inline stylesheet");
info("Waiting for the stylesheet editor to be selected");
@ -112,10 +112,10 @@ function* testSecondInlineStyleSheet(view, toolbox) {
is(toolbox.currentToolId, "styleeditor",
"The style editor is selected again");
validateStyleEditorSheet(editor, 1);
yield validateStyleEditorSheet(editor, 1, testActor);
}
function* testExternalStyleSheet(view, toolbox) {
function* testExternalStyleSheet(view, toolbox, testActor) {
info("Testing external stylesheet");
info("Waiting for the stylesheet editor to be selected");
@ -132,17 +132,21 @@ function* testExternalStyleSheet(view, toolbox) {
is(toolbox.currentToolId, "styleeditor",
"The style editor is selected again");
validateStyleEditorSheet(editor, 2);
yield validateStyleEditorSheet(editor, 2, testActor);
}
function validateStyleEditorSheet(editor, expectedSheetIndex) {
function* validateStyleEditorSheet(editor, expectedSheetIndex, testActor) {
info("validating style editor stylesheet");
is(editor.styleSheet.styleSheetIndex, expectedSheetIndex,
"loaded stylesheet index matches document stylesheet");
let sheet = content.document.styleSheets[expectedSheetIndex];
is(editor.styleSheet.href, sheet.href,
"loaded stylesheet href matches document stylesheet");
let href = editor.styleSheet.href || editor.styleSheet.nodeHref;
let expectedHref = yield testActor.eval(
`content.document.styleSheets[${expectedSheetIndex}].href ||
content.document.location.href`);
is(href, expectedHref, "loaded stylesheet href matches document stylesheet");
}
function testRuleViewLinkLabel(view) {