Bug 1726004 - [devtools] Remove backward compatibility code for descriptor reload r=bomsy,devtools-backward-compat-reviewers
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 23 Aug 2021 07:59:09 +0000
changeset 589535 a2ddceb4895bbb56add6ceceacb1358b99c9b074
parent 589534 0322c520d7c650475d68399bc9136d3c50f23e5f
child 589536 fddd1f768e106f66525f002c211df992da982caf
push id38727
push userapavel@mozilla.com
push dateMon, 23 Aug 2021 15:55:22 +0000
treeherdermozilla-central@108a81c39b3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbomsy, devtools-backward-compat-reviewers
bugs1726004
milestone93.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 1726004 - [devtools] Remove backward compatibility code for descriptor reload r=bomsy,devtools-backward-compat-reviewers Depends on D122761 Differential Revision: https://phabricator.services.mozilla.com/D122762
devtools/shared/commands/target/target-command.js
devtools/shared/commands/target/tests/browser_target_command_reload.js
devtools/shared/specs/targets/browsing-context.js
--- a/devtools/shared/commands/target/target-command.js
+++ b/devtools/shared/commands/target/target-command.js
@@ -783,25 +783,18 @@ class TargetCommand extends EventEmitter
   /**
    * Reload the current top level target.
    * This only works for targets inheriting from BrowsingContextTarget.
    *
    * @param {Boolean} bypassCache
    *        If true, the reload will be forced to bypass any cache.
    */
   async reloadTopLevelTarget(bypassCache = false) {
-    // @backward-compat { version 91 }
-    //                  BrowsingContextTargetActor.reload was moved to descriptors.
-    //                  After release 91 is on the release channel, we can check
-    //                  this.descriptorFront.traits.supportsReloadDescriptor
-    //                  instead.
-    if (!this.targetFront.isBrowsingContext) {
-      throw new Error(
-        "The top level target isn't a BrowsingContext and doesn't support being reloaded"
-      );
+    if (!this.descriptorFront.traits.supportsReloadDescriptor) {
+      throw new Error("The top level target doesn't support being reloaded");
     }
 
     // Wait for the next DOCUMENT_EVENT's dom-complete event
     // Wait for waitForNextResource completion before reloading, otherwise we might miss the dom-complete event.
     // This can happen if `ResourceCommand.watchResources` made by `waitForNextResource` is still pending
     // while the reload already started and finished loading the document early.
     const {
       onResource: onReloaded,
@@ -810,43 +803,21 @@ class TargetCommand extends EventEmitter
       {
         ignoreExistingResources: true,
         predicate(resource) {
           return resource.name == "dom-complete";
         },
       }
     );
 
-    // @backward-compat { version 91 }
-    //                  BrowsingContextTargetActor.reload was moved to descriptors.
-    if (this.descriptorFront.traits.supportsReloadDescriptor) {
-      await this.descriptorFront.reloadDescriptor({ bypassCache });
-    } else {
-      await this._legacyTargetActorReload(bypassCache);
-    }
+    await this.descriptorFront.reloadDescriptor({ bypassCache });
 
     await onReloaded;
   }
 
-  async _legacyTargetActorReload(force) {
-    const { targetFront } = this;
-    try {
-      // Arguments of reload are a bit convoluted.
-      // We expect an dictionary object, which only support one attribute
-      // called "force" which force bypassing the caches.
-      await targetFront.reload({ options: { force } });
-    } catch (e) {
-      // If the target follows the window global lifecycle, the reload request
-      // will fail, and we should swallow the error. Re-throw it otherwise.
-      if (!targetFront.targetForm.followWindowGlobalLifeCycle) {
-        throw e;
-      }
-    }
-  }
-
   /**
    * Called when the top level target is replaced by a new one.
    * Typically when we navigate to another domain which requires to be loaded in a distinct process.
    *
    * @param {TargetFront} newTarget
    *        The new top level target to debug.
    */
   async switchToTarget(newTarget) {
--- a/devtools/shared/commands/target/tests/browser_target_command_reload.js
+++ b/devtools/shared/commands/target/tests/browser_target_command_reload.js
@@ -74,20 +74,17 @@ add_task(async function() {
 
   // We have to start listening in order to ensure having a targetFront available
   await commands.targetCommand.startListening();
 
   try {
     await commands.targetCommand.reloadTopLevelTarget();
     ok(false, "reloadToLevelTarget() should have thrown for the main process");
   } catch (e) {
-    is(
-      e.message,
-      "The top level target isn't a BrowsingContext and doesn't support being reloaded"
-    );
+    is(e.message, "The top level target doesn't support being reloaded");
   }
   await commands.destroy();
 });
 
 function getContentVariable() {
   return SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
     return content.wrappedJSObject.jsValue;
   });
--- a/devtools/shared/specs/targets/browsing-context.js
+++ b/devtools/shared/specs/targets/browsing-context.js
@@ -32,19 +32,16 @@ types.addDictType("browsingContextTarget
   title: "nullable:string", // should be present if not destroying
   destroy: "nullable:boolean", // not present if not destroying
 });
 
 types.addDictType("browsingContextTarget.workers", {
   workers: "array:workerDescriptor",
 });
 
-// @backward-compat { version 91 }
-//                  BrowsingContextTarget reload should no longer be used within
-//                  DevTools. Remove this comment when version 91 hits release.
 // @backward-compat { legacy }
 //                  reload is preserved for third party tools. See Bug 1717837.
 //                  DevTools should use Descriptor::reloadDescriptor instead.
 types.addDictType("browsingContextTarget.reload", {
   force: "boolean",
 });
 
 // @backward-compat { version 87 } See backward-compat note for `reconfigure`.
@@ -80,23 +77,19 @@ const browsingContextTargetSpecPrototype
     goForward: {
       request: {},
       response: {},
     },
     goBack: {
       request: {},
       response: {},
     },
-    // @backward-compat { version 91 }
-    //                  BrowsingContextTarget reload should no longer be used within
-    //                  DevTools. Remove this comment when version 91 hits release.
     // @backward-compat { legacy }
     //                  reload is preserved for third party tools. See Bug 1717837.
     //                  DevTools should use Descriptor::reloadDescriptor instead.
-
     reload: {
       request: {
         options: Option(0, "browsingContextTarget.reload"),
       },
       response: {},
     },
     navigateTo: {
       request: {