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
--- 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.
*