Bug 1615283 - Redirect old inspector "navigateTo" to the new shared helper. r=nchevobbe
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 17 Feb 2020 16:52:34 +0000
changeset 514338 cd53a0220c505f3dafd54b51071e4a2fe24c25a1
parent 514337 a838dc056fa9e1041ff06c92d41f09eba98aa415
child 514339 400f79b41c4ba3a045c4a6e9f25ef1553142c847
push id107514
push userapoirot@mozilla.com
push dateMon, 17 Feb 2020 16:53:40 +0000
treeherderautoland@cd53a0220c50 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1615283
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1615283 - Redirect old inspector "navigateTo" to the new shared helper. r=nchevobbe As for the console, we don't really have to pass a context as we always navigate in the foremost tab. We would need to pass a context if the tab was in background. Differential Revision: https://phabricator.services.mozilla.com/D62807
devtools/client/inspector/grids/test/browser_grids_number-of-css-grids-telemetry.js
devtools/client/inspector/grids/test/browser_grids_restored-after-reload.js
devtools/client/inspector/markup/test/browser_markup_events_source_map.js
devtools/client/inspector/rules/test/browser_rules_eyedropper.js
devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-on-navigate.js
devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-restored-after-reload.js
devtools/client/inspector/rules/test/browser_rules_grid-highlighter-on-navigate.js
devtools/client/inspector/rules/test/browser_rules_grid-highlighter-restored-after-reload.js
devtools/client/inspector/rules/test/browser_rules_selector-highlighter-on-navigate.js
devtools/client/inspector/test/browser_inspector_destroy-after-navigation.js
devtools/client/inspector/test/browser_inspector_highlighter-05.js
devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-xul.js
devtools/client/inspector/test/browser_inspector_navigate_to_errors.js
devtools/client/inspector/test/browser_inspector_navigation.js
devtools/client/inspector/test/browser_inspector_open_on_neterror.js
devtools/client/inspector/test/browser_inspector_select-last-selected.js
devtools/client/inspector/test/head.js
--- a/devtools/client/inspector/grids/test/browser_grids_number-of-css-grids-telemetry.js
+++ b/devtools/client/inspector/grids/test/browser_grids_number-of-css-grids-telemetry.js
@@ -32,17 +32,16 @@ add_task(async function() {
 
   info("Navigate to TEST_URI2");
 
   const onGridListUpdate = waitUntilState(
     store,
     state => state.grids.length == 1
   );
   await navigateTo(
-    inspector,
     "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI2)
   );
   await onGridListUpdate;
 
   checkResults();
 });
 
 function checkResults() {
--- a/devtools/client/inspector/grids/test/browser_grids_restored-after-reload.js
+++ b/devtools/client/inspector/grids/test/browser_grids_restored-after-reload.js
@@ -96,17 +96,17 @@ add_task(async function() {
   );
   const otherUri =
     "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI);
   onStateRestored = highlighters.once("grid-state-restored");
   onGridListRestored = waitUntilState(
     store,
     state => state.grids.length == 1 && !state.grids[0].highlighted
   );
-  await navigateTo(inspector, otherUri);
+  await navigateTo(otherUri);
   ({ restored } = await onStateRestored);
   await onGridListRestored;
 
   info(
     "Check that the grid highlighter is hidden after navigating to a different page"
   );
   ok(!restored, "The highlighter state was not restored");
   ok(!highlighters.gridHighlighters.size, "CSS grid highlighter is hidden.");
--- a/devtools/client/inspector/markup/test/browser_markup_events_source_map.js
+++ b/devtools/client/inspector/markup/test/browser_markup_events_source_map.js
@@ -36,17 +36,17 @@ add_task(async function() {
     INITIAL_URL
   );
 
   // Ensure the source map service is operating.  This looks a bit
   // funny, but sourceMapURLService is a getter, and we don't need the
   // result.
   toolbox.sourceMapURLService;
 
-  await navigateTo(inspector, TEST_URL);
+  await navigateTo(TEST_URL);
 
   await inspector.markup.expandAll();
 
   for (const test of TEST_DATA) {
     await checkEventsForNode(test, inspector, testActor);
   }
 
   // Wait for promises to avoid leaks when running this as a single test.
--- a/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
+++ b/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
@@ -44,17 +44,17 @@ add_task(async function() {
   const url = "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI);
   await addTab(url);
 
   const { testActor, inspector, view, toolbox } = await openRuleView();
 
   await runTest(testActor, inspector, view, false);
 
   info("Reload the page to restore the initial state");
-  await navigateTo(inspector, url);
+  await navigateTo(url);
 
   info("Change toolbox host to WINDOW");
   await toolbox.switchHost("window");
 
   // Switching hosts is not correctly waiting when DevTools run in content frame
   // See Bug 1571421.
   await wait(1000);
 
--- a/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-on-navigate.js
+++ b/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-on-navigate.js
@@ -26,11 +26,11 @@ add_task(async function() {
   const flexboxToggle = container.querySelector(".ruleview-flex");
 
   info("Toggling ON the flexbox highlighter from the rule-view.");
   const onHighlighterShown = highlighters.once("flexbox-highlighter-shown");
   flexboxToggle.click();
   await onHighlighterShown;
   ok(highlighters.flexboxHighlighterShown, "Flexbox highlighter is shown.");
 
-  await navigateTo(inspector, TEST_URI_2);
+  await navigateTo(TEST_URI_2);
   ok(!highlighters.flexboxHighlighterShown, "Flexbox highlighter is hidden.");
 });
--- a/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-restored-after-reload.js
+++ b/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-restored-after-reload.js
@@ -56,13 +56,13 @@ add_task(async function() {
     "Check that the flexbox highlighter can be displayed after reloading the page"
   );
   ok(highlighters.flexboxHighlighterShown, "Flexbox highlighter is shown.");
 
   info("Navigate to another URL, and check that the highlighter is hidden");
   const otherUri =
     "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI);
   onStateRestored = highlighters.once("flexbox-state-restored");
-  await navigateTo(inspector, otherUri);
+  await navigateTo(otherUri);
   ({ restored } = await onStateRestored);
   ok(!restored, "The highlighter state was not restored");
   ok(!highlighters.flexboxHighlighterShown, "Flexbox highlighter is hidden.");
 });
--- a/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-on-navigate.js
+++ b/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-on-navigate.js
@@ -30,11 +30,11 @@ add_task(async function() {
 
   info("Toggling ON the CSS grid highlighter from the rule-view.");
   const onHighlighterShown = highlighters.once("grid-highlighter-shown");
   gridToggle.click();
   await onHighlighterShown;
 
   is(highlighters.gridHighlighters.size, 1, "CSS grid highlighter is shown.");
 
-  await navigateTo(inspector, TEST_URI_2);
+  await navigateTo(TEST_URI_2);
   ok(!highlighters.gridHighlighters.size, "CSS grid highlighter is hidden.");
 });
--- a/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-restored-after-reload.js
+++ b/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-restored-after-reload.js
@@ -63,13 +63,13 @@ add_task(async function() {
     "Check that the grid highlighter can be displayed after reloading the page"
   );
   is(highlighters.gridHighlighters.size, 1, "CSS grid highlighter is shown.");
 
   info("Navigate to another URL, and check that the highlighter is hidden");
   const otherUri =
     "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI);
   onStateRestored = highlighters.once("grid-state-restored");
-  await navigateTo(inspector, otherUri);
+  await navigateTo(otherUri);
   ({ restored } = await onStateRestored);
   ok(!restored, "The highlighter state was not restored");
   ok(!highlighters.gridHighlighters.size, "CSS grid highlighter is hidden.");
 });
--- a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter-on-navigate.js
+++ b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter-on-navigate.js
@@ -13,31 +13,31 @@ const TEST_URI = `
   </style>
   Test the selector highlighter
 `;
 
 const TEST_URI_2 = "data:text/html,<html><body>test</body></html>";
 
 add_task(async function() {
   await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
-  const { inspector, view } = await openRuleView();
+  const { view } = await openRuleView();
   const highlighters = view.highlighters;
 
   info("Clicking on a selector icon");
   const icon = await getRuleViewSelectorHighlighterIcon(view, "body, p, td");
 
   const onToggled = view.once("ruleview-selectorhighlighter-toggled");
   EventUtils.synthesizeMouseAtCenter(icon, {}, view.styleWindow);
   const isVisible = await onToggled;
 
   ok(
     highlighters.selectorHighlighterShown,
     "The selectorHighlighterShown is set."
   );
   ok(view.selectorHighlighter, "The selectorhighlighter instance was created");
   ok(isVisible, "The toggle event says the highlighter is visible");
 
-  await navigateTo(inspector, TEST_URI_2);
+  await navigateTo(TEST_URI_2);
   ok(
     !highlighters.selectorHighlighterShown,
     "The selectorHighlighterShown is unset."
   );
 });
--- a/devtools/client/inspector/test/browser_inspector_destroy-after-navigation.js
+++ b/devtools/client/inspector/test/browser_inspector_destroy-after-navigation.js
@@ -3,19 +3,19 @@
 "use strict";
 
 // Testing that closing the inspector after navigating to a page doesn't fail.
 
 const URL_1 = "data:text/plain;charset=UTF-8,abcde";
 const URL_2 = "data:text/plain;charset=UTF-8,12345";
 
 add_task(async function() {
-  const { inspector, toolbox } = await openInspectorForURL(URL_1);
+  const { toolbox } = await openInspectorForURL(URL_1);
 
-  await navigateTo(inspector, URL_2);
+  await navigateTo(URL_2);
 
   info("Destroying toolbox");
   try {
     await toolbox.destroy();
     ok(true, "Toolbox destroyed");
   } catch (e) {
     ok(false, "An exception occured while destroying toolbox");
     console.error(e);
--- a/devtools/client/inspector/test/browser_inspector_highlighter-05.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-05.js
@@ -45,25 +45,20 @@ const TEST_URL =
     <body>
       <p>Slow page</p>
      </body>
   </html>
 `);
 
 add_task(async function() {
   info("Open the inspector to a blank page.");
-  const { inspector, tab, testActor } = await openInspectorForURL(
-    "about:blank"
-  );
-
-  const pageLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+  const { inspector, testActor } = await openInspectorForURL("about:blank");
 
   info("Navigate to the test url and waiting for the page to be loaded.");
-  await navigateTo(inspector, TEST_URL);
-  await pageLoaded;
+  await navigateTo(TEST_URL);
 
   info("Shows the box model highligher for the <p> node.");
   const divFront = await getNodeFront("p", inspector);
   await inspector.highlighter.showBoxModel(divFront);
 
   info("Check the node is highlighted.");
   is(
     await testActor.isHighlighting(),
--- a/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-xul.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-xul.js
@@ -31,17 +31,17 @@ add_task(async function() {
   swatchEl.click();
   await onColorPickerReady;
 
   button = cPicker.tooltip.container.querySelector("#eyedropper-button");
   ok(isDisabled(button), "The button is disabled in the color picker");
 
   info("Navigate to a HTML document");
   const toolbarUpdated = inspector.once("inspector-toolbar-updated");
-  await navigateTo(inspector, TEST_URL_2);
+  await navigateTo(TEST_URL_2);
   await toolbarUpdated;
 
   info("Check the inspector toolbar in HTML document");
   button = inspector.panelDoc.querySelector("#inspector-eyedropper-toggle");
   ok(!isDisabled(button), "The button is enabled in the toolbar");
 
   info("Check the color picker in HTML document");
   // Find the color swatch in the rule-view.
--- a/devtools/client/inspector/test/browser_inspector_navigate_to_errors.js
+++ b/devtools/client/inspector/test/browser_inspector_navigate_to_errors.js
@@ -11,17 +11,17 @@ const TEST_URL_2 = "http://127.0.0.1:363
 const TEST_URL_3 = "http://www.wronguri.wronguri/";
 const TEST_URL_4 = "data:text/html,<html><body>test-doc-4</body></html>";
 
 add_task(async function() {
   // Open the inspector on a valid URL
   const { inspector, testActor } = await openInspectorForURL(TEST_URL_1);
 
   info("Navigate to closed port");
-  await navigateTo(inspector, TEST_URL_2);
+  await navigateTo(TEST_URL_2, { isErrorPage: true });
 
   const documentURI = await testActor.eval("document.documentURI;");
   ok(documentURI.startsWith("about:neterror"), "content is correct.");
 
   const hasPage = await getNodeFront("#test-doc-1", inspector);
   ok(
     !hasPage,
     "Inspector actor is no longer able to reach previous page DOM node"
@@ -37,27 +37,27 @@ add_task(async function() {
   let errorMsg = bundle.formatStringFromName("connectionFailure", [domain]);
   is(
     await getDisplayedNodeTextContent("#errorShortDescText", inspector),
     errorMsg,
     "Inpector really inspects the error page"
   );
 
   info("Navigate to unknown domain");
-  await navigateTo(inspector, TEST_URL_3);
+  await navigateTo(TEST_URL_3, { isErrorPage: true });
 
   domain = TEST_URL_3.match(/^http:\/\/(.*)\/$/)[1];
   errorMsg = bundle.formatStringFromName("dnsNotFound2", [domain]);
   is(
     await getDisplayedNodeTextContent("#errorShortDescText", inspector),
     errorMsg,
     "Inspector really inspects the new error page"
   );
 
   info("Navigate to a valid url");
-  await navigateTo(inspector, TEST_URL_4);
+  await navigateTo(TEST_URL_4);
 
   is(
     await getDisplayedNodeTextContent("body", inspector),
     "test-doc-4",
     "Inspector really inspects the valid url"
   );
 });
--- a/devtools/client/inspector/test/browser_inspector_navigation.js
+++ b/devtools/client/inspector/test/browser_inspector_navigation.js
@@ -20,17 +20,17 @@ const TEST_URL_4 =
   "data:text/html;charset=utf-8," + encodeURIComponent("<h1>bar</h1>");
 
 add_task(async function() {
   const { inspector, testActor } = await openInspectorForURL(TEST_URL_1);
 
   await selectNode("#i1", inspector);
 
   info("Navigating to a different page.");
-  await navigateTo(inspector, TEST_URL_2);
+  await navigateTo(TEST_URL_2);
 
   ok(true, "New page loaded");
   await selectNode("#i1", inspector);
 
   const markuploaded = inspector.once("markuploaded");
   const onUpdated = inspector.once("inspector-updated");
 
   info("Going back in history");
@@ -49,17 +49,17 @@ add_task(async function() {
 });
 
 add_task(async function() {
   const { inspector, testActor } = await openInspectorForURL(TEST_URL_3);
 
   await selectNode("img", inspector);
 
   info("Navigating to a different page.");
-  await navigateTo(inspector, TEST_URL_4);
+  await navigateTo(TEST_URL_4);
 
   ok(true, "New page loaded");
   await selectNode("#h1", inspector);
 
   const markuploaded = inspector.once("markuploaded");
   const onUpdated = inspector.once("inspector-updated");
 
   info("Going back in history");
--- a/devtools/client/inspector/test/browser_inspector_open_on_neterror.js
+++ b/devtools/client/inspector/test/browser_inspector_open_on_neterror.js
@@ -38,16 +38,16 @@ add_task(async function() {
 
   const documentURI = await testActor.eval("document.documentURI;");
   ok(
     documentURI.startsWith("about:neterror"),
     "content is really a net error page."
   );
 
   info("Navigate to a valid url");
-  await navigateTo(inspector, TEST_URL_2);
+  await navigateTo(TEST_URL_2);
 
   is(
     await getDisplayedNodeTextContent("body", inspector),
     "test-doc-2",
     "Inspector really inspects the valid url"
   );
 });
--- a/devtools/client/inspector/test/browser_inspector_select-last-selected.js
+++ b/devtools/client/inspector/test/browser_inspector_select-last-selected.js
@@ -84,12 +84,12 @@ add_task(async function() {
       const onUpdated = inspector.once("inspector-updated");
 
       await toolbox.target.reload();
       info("Waiting for inspector to be ready.");
       await markuploaded;
       await onNewRoot;
       await onUpdated;
     } else {
-      await navigateTo(inspector, url);
+      await navigateTo(url);
     }
   }
 });
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -43,39 +43,16 @@ registerCleanupFunction(function() {
   EventUtils.synthesizeMouseAtPoint(
     window.innerWidth,
     1,
     { type: "mousemove" },
     window
   );
 });
 
-var navigateTo = async function(inspector, url) {
-  const markuploaded = inspector.once("markuploaded");
-  const onNewRoot = inspector.once("new-root");
-  const onUpdated = inspector.once("inspector-updated");
-  const onReloaded = inspector.once("reloaded");
-
-  info("Navigating to: " + url);
-  const target = inspector.toolbox.target;
-  await target.navigateTo({ url });
-
-  info("Waiting for markup view to load after navigation.");
-  await markuploaded;
-
-  info("Waiting for new root.");
-  await onNewRoot;
-
-  info("Waiting for inspector to update after new-root event.");
-  await onUpdated;
-
-  info("Waiting for inspector updates after page reload");
-  await onReloaded;
-};
-
 /**
  * Start the element picker and focus the content window.
  * @param {Toolbox} toolbox
  * @param {Boolean} skipFocus - Allow tests to bypass the focus event.
  */
 var startPicker = async function(toolbox, skipFocus) {
   info("Start the element picker");
   toolbox.win.focus();