Bug 1431151 - Include outerWindowID in error message for assert.open. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 17 Jan 2018 17:44:58 +0000
changeset 723106 6d6a3258d31fd7e15eb583b8d826f10c75bc3945
parent 723064 3d23e6d98a09a3395bf2b0d9cb03dd4be358c715
child 746779 bd56768a943f95a26d2f78dd83bf3e426f12380a
push id96339
push userbmo:ato@sny.no
push dateMon, 22 Jan 2018 16:39:55 +0000
reviewerswhimboo
bugs1431151
milestone60.0a1
Bug 1431151 - Include outerWindowID in error message for assert.open. r?whimboo When given a browser.Context assert.open will include its curFrameId property, which is effectively the outerWindowID, when the assertion fails. Because GeckoDriver#getCurrentWindow() always returns null we can't look up the ChromeWindow outerWindowID. It is worth noting that following https://bugzil.la/marionette-window-tracking it will be possible to significantly shorten assert.open because the context argument will always be populated, and ChromeWindow and browsing.Context will share the same interface. MozReview-Commit-ID: FZdYkCn9yX3
testing/marionette/assert.js
--- a/testing/marionette/assert.js
+++ b/testing/marionette/assert.js
@@ -154,17 +154,24 @@ assert.content = function(context, msg =
 assert.open = function(context, msg = "") {
   // TODO: The contentBrowser uses a cached tab, which is only updated when
   // switchToTab is called. Because of that an additional check is needed to
   // make sure that the chrome window has not already been closed.
   if (context instanceof browser.Context) {
     assert.open(context.window);
   }
 
-  msg = msg || "Browsing context has been discarded";
+  if (!msg) {
+    if (context instanceof browser.Context) {
+      msg = `Browsing context ${context.curFrameId} has been discarded`;
+    } else {
+      msg = "Browsing context has been discarded";
+    }
+  }
+
   return assert.that(ctx => ctx && !ctx.closed,
       msg,
       NoSuchWindowError)(context);
 };
 
 /**
  * Asserts that there is no current user prompt.
  *