Bug 1246677 - 6 - Get rid of 'content' in ruleview head.js
MozReview-Commit-ID: A1r7oVz0cbV
--- a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js
@@ -53,23 +53,23 @@ var testData = [
["i", "fiill", -1, 0],
["VK_ESCAPE", null, -1, 0],
];
const TEST_URI = "<h1 style='font: 24px serif'>Header</h1>";
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
- let {toolbox, inspector, view} = yield openRuleView();
+ let {toolbox, inspector, view, testActor} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
- yield reloadPage(inspector);
+ yield reloadPage(inspector, testActor);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
info("Focusing the css property editable field");
@@ -97,17 +97,17 @@ function* testCompletion([key, completio
info("Waiting for after-suggest event on the editor");
onSuggest = editor.once("after-suggest");
}
info("Synthesizing key " + key);
EventUtils.synthesizeKey(key, {}, view.styleWindow);
yield onSuggest;
- yield wait(1); // Equivalent of executeSoon
+ yield waitForTick();
info("Checking the state");
if (completion != null) {
is(editor.input.value, completion, "Correct value is autocompleted");
}
if (total == 0) {
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
} else {
--- a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_02.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_02.js
@@ -35,23 +35,23 @@ var testData = [
["n", {}, "none", -1, 0],
["VK_RETURN", {}, null, -1, 0]
];
const TEST_URI = "<h1 style='color: red'>Header</h1>";
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
- let {toolbox, inspector, view} = yield openRuleView();
+ let {toolbox, inspector, view, testActor} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
- yield reloadPage(inspector);
+ yield reloadPage(inspector, testActor);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
info("Focusing the css property editable value");
@@ -85,17 +85,17 @@ function* testCompletion([key, modifiers
info("Waiting for after-suggest event on the editor");
onKeyPress = editor.once("after-suggest");
}
info("Synthesizing key " + key + ", modifiers: " + Object.keys(modifiers));
EventUtils.synthesizeKey(key, modifiers, view.styleWindow);
yield onKeyPress;
- yield wait(1); // Equivalent of executeSoon
+ yield waitForTick();
// The key might have been a TAB or shift-TAB, in which case the editor will
// be a new one
editor = inplaceEditor(view.styleDocument.activeElement);
info("Checking the state");
if (completion != null) {
is(editor.input.value, completion, "Correct value is autocompleted");
--- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_01.js
@@ -36,23 +36,23 @@ var testData = [
["i", "fill", 0, 4],
["VK_ESCAPE", null, -1, 0],
];
const TEST_URI = "<h1 style='border: 1px solid red'>Header</h1>";
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
- let {toolbox, inspector, view} = yield openRuleView();
+ let {toolbox, inspector, view, testActor} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
- yield reloadPage(inspector);
+ yield reloadPage(inspector, testActor);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
info("Focusing the css property editable field");
@@ -78,17 +78,17 @@ function* testCompletion([key, completio
info("Waiting for after-suggest event on the editor");
onSuggest = editor.once("after-suggest");
}
info("Synthesizing key " + key);
EventUtils.synthesizeKey(key, {}, view.styleWindow);
yield onSuggest;
- yield wait(1); // Equivalent of executeSoon
+ yield waitForTick();
info("Checking the state");
if (completion != null) {
is(editor.input.value, completion, "Correct value is autocompleted");
}
if (total == 0) {
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
} else {
--- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_02.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_02.js
@@ -45,23 +45,23 @@ const TEST_URI = `
border: 1px solid red;
}
</style>
<h1>Test element</h1>
`;
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
- let {toolbox, inspector, view} = yield openRuleView();
+ let {toolbox, inspector, view, testActor} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
- yield reloadPage(inspector);
+ yield reloadPage(inspector, testActor);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
info("Focusing a new css property editable property");
@@ -96,17 +96,17 @@ function* testCompletion([key, modifiers
info("Waiting for after-suggest event on the editor");
onKeyPress = editor.once("after-suggest");
}
info("Synthesizing key " + key + ", modifiers: " + Object.keys(modifiers));
EventUtils.synthesizeKey(key, modifiers, view.styleWindow);
yield onKeyPress;
- yield wait(1); // Equivalent of executeSoon
+ yield waitForTick();
info("Checking the state");
if (completion != null) {
// The key might have been a TAB or shift-TAB, in which case the editor will
// be a new one
editor = inplaceEditor(view.styleDocument.activeElement);
is(editor.input.value, completion, "Correct value is autocompleted");
}
--- a/devtools/client/inspector/rules/test/browser_rules_completion-popup-hidden-after-navigation.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-popup-hidden-after-navigation.js
@@ -5,17 +5,17 @@
"use strict";
// Tests that the ruleview autocomplete popup is hidden after page navigation.
const TEST_URI = "<h1 style='font: 24px serif'></h1>";
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();
info("Test autocompletion popup is hidden after page navigation");
info("Selecting the test node");
yield selectNode("h1", inspector);
info("Focusing the css property editable field");
let propertyName = view.styleDocument
@@ -23,17 +23,17 @@ add_task(function*() {
let editor = yield focusEditableField(view, propertyName);
info("Pressing key VK_DOWN");
let onSuggest = once(editor.input, "keypress");
EventUtils.synthesizeKey("VK_DOWN", {}, view.styleWindow);
info("Waiting for autocomplete popup to be displayed");
yield onSuggest;
- yield wait(1);
+ yield waitForTick();
ok(view.popup && view.popup.isOpen, "Popup should be opened");
info("Reloading the page");
- yield reloadPage(inspector);
+ yield reloadPage(inspector, testActor);
ok(!(view.popup && view.popup.isOpen), "Popup should be closed");
});
--- a/devtools/client/inspector/rules/test/browser_rules_user-property-reset.js
+++ b/devtools/client/inspector/rules/test/browser_rules_user-property-reset.js
@@ -9,28 +9,28 @@
const TEST_URI = `
<p id='id1' style='width:200px;'>element 1</p>
<p id='id2' style='width:100px;'>element 2</p>
`;
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();
yield selectNode("#id1", inspector);
yield modifyRuleViewWidth("300px", view, inspector);
yield assertRuleAndMarkupViewWidth("id1", "300px", view, inspector);
yield selectNode("#id2", inspector);
yield assertRuleAndMarkupViewWidth("id2", "100px", view, inspector);
yield modifyRuleViewWidth("50px", view, inspector);
yield assertRuleAndMarkupViewWidth("id2", "50px", view, inspector);
- yield reloadPage(inspector);
+ yield reloadPage(inspector, testActor);
yield selectNode("#id1", inspector);
yield assertRuleAndMarkupViewWidth("id1", "200px", view, inspector);
yield selectNode("#id2", inspector);
yield assertRuleAndMarkupViewWidth("id2", "100px", view, inspector);
});
function getStyleRule(ruleView) {
--- a/devtools/client/inspector/rules/test/head.js
+++ b/devtools/client/inspector/rules/test/head.js
@@ -106,30 +106,16 @@ function waitForNEvents(target, eventNam
break;
}
}
return deferred.promise;
}
/**
- * This shouldn't be used in the tests, but is useful when writing new tests or
- * debugging existing tests in order to introduce delays in the test steps
- *
- * @param {Number} ms
- * The time to wait
- * @return A promise that resolves when the time is passed
- */
-function wait(ms) {
- let def = promise.defer();
- content.setTimeout(def.resolve, ms);
- return def.promise;
-}
-
-/**
* Wait for a content -> chrome message on the message manager (the window
* messagemanager is used).
*
* @param {String} name
* The message name
* @return {Promise} A promise that resolves to the response data when the
* message has been received
*/
@@ -748,15 +734,14 @@ var setSearchFilter = Task.async(functio
* Reload the current page and wait for the inspector to be initialized after
* the navigation
*
* @param {InspectorPanel} inspector
* The instance of InspectorPanel currently loaded in the toolbox
* @return a promise that resolves after page reload and inspector
* initialization
*/
-function reloadPage(inspector) {
+function* reloadPage(inspector, testActor) {
let onNewRoot = inspector.once("new-root");
- content.location.reload();
- return onNewRoot.then(() => {
- inspector.markup._waitForChildren();
- });
+ yield testActor.eval("content.location.reload();");
+ yield onNewRoot;
+ yield inspector.markup._waitForChildren();
}