Skip to content

Commit

Permalink
Bug 1873948 - [webdriver-bidi] "browsingContext.close" should be able…
Browse files Browse the repository at this point in the history
… to close the last tab of a window. r=webdriver-reviewers,Sasha

This also removes the custom value of the recommended
preference `browser.tabs.closeWindowWithLastTab` because
it's not needed anymore.

Differential Revision: https://phabricator.services.mozilla.com/D199134
  • Loading branch information
whimboo committed Jan 22, 2024
1 parent 363a33c commit 78c3eb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
3 changes: 0 additions & 3 deletions remote/shared/RecommendedPreferences.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ const COMMON_PREFERENCES = new Map([
// Do not redirect user when a milstone upgrade of Firefox is detected
["browser.startup.homepage_override.mstone", "ignore"],

// Do not close the window when the last tab gets closed
["browser.tabs.closeWindowWithLastTab", false],

// Don't unload tabs when available memory is running low
["browser.tabs.unloadOnLowMemory", false],

Expand Down
14 changes: 4 additions & 10 deletions remote/webdriver-bidi/modules/root/browsingContext.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
error: "chrome://remote/content/shared/webdriver/Errors.sys.mjs",
EventPromise: "chrome://remote/content/shared/Sync.sys.mjs",
getTimeoutMultiplier: "chrome://remote/content/shared/AppInfo.sys.mjs",
Log: "chrome://remote/content/shared/Log.sys.mjs",
modal: "chrome://remote/content/shared/Prompt.sys.mjs",
registerNavigationId:
"chrome://remote/content/shared/NavigationManager.sys.mjs",
Expand All @@ -40,10 +39,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
windowManager: "chrome://remote/content/shared/WindowManager.sys.mjs",
});

ChromeUtils.defineLazyGetter(lazy, "logger", () =>
lazy.Log.get(lazy.Log.TYPES.WEBDRIVER_BIDI)
);

// Maximal window dimension allowed when emulating a viewport.
const MAX_WINDOW_SIZE = 10000000;

Expand Down Expand Up @@ -415,11 +410,10 @@ class BrowsingContextModule extends Module {
}

if (lazy.TabManager.getTabCount() === 1) {
// The behavior when closing the last tab is currently unspecified.
// Warn the consumer about potential issues
lazy.logger.warn(
`Closing the last open tab (Browsing Context id ${contextId}), expect inconsistent behavior across platforms`
);
// The behavior when closing the very last tab is currently unspecified.
// As such behave like Marionette and don't allow closing it.
// See: https://github.com/w3c/webdriver-bidi/issues/187
return;
}

const tab = lazy.TabManager.getTabForBrowsingContext(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
[close.py]
expected:
if (processor == "x86") and not debug: [OK, TIMEOUT]
[test_top_level_context[window\]]
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1873948
expected:
if os == "android": PASS
FAIL

0 comments on commit 78c3eb9

Please sign in to comment.