зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1665437 - [marionette] Fix race between "WebDriver:CloseChromeWindow" and next browsing context check. r=marionette-reviewers,maja_zf
Similar to closing a tab the internal browsing contexts need to be nullified. This is necessary because browsing contexts are asynchronously discarded and garbage collected. Also the "unload" event as currently used to wait for the chrome window to be closed fires too early. Instead the "xul-window-destroyed" observer notification needs to be used. Differential Revision: https://phabricator.services.mozilla.com/D91296
This commit is contained in:
Родитель
13dc789969
Коммит
08d5370559
|
@ -275,15 +275,14 @@ browser.Context = class {
|
|||
* @return {Promise}
|
||||
* A promise which is resolved when the current window has been closed.
|
||||
*/
|
||||
closeWindow() {
|
||||
let destroyed = new MessageManagerDestroyedPromise(
|
||||
this.window.messageManager
|
||||
);
|
||||
let unloaded = waitForEvent(this.window, "unload");
|
||||
async closeWindow() {
|
||||
const destroyed = waitForObserverTopic("xul-window-destroyed", {
|
||||
checkFn: () => this.window && this.window.closed,
|
||||
});
|
||||
|
||||
this.window.close();
|
||||
|
||||
return Promise.all([destroyed, unloaded]);
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2936,6 +2936,9 @@ GeckoDriver.prototype.closeChromeWindow = async function() {
|
|||
}
|
||||
|
||||
await this.curBrowser.closeWindow();
|
||||
this.chromeBrowsingContext = null;
|
||||
this.contentBrowsingContext = null;
|
||||
|
||||
return this.chromeWindowHandles.map(String);
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
from marionette_driver import By
|
||||
from marionette_driver.errors import NoSuchWindowException
|
||||
|
@ -27,6 +27,7 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
|
||||
# When closing a browser window both handles are not available
|
||||
for context in ("chrome", "content"):
|
||||
print("Testing handles with context {}".format(context))
|
||||
with self.marionette.using_context(context):
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
|
Загрузка…
Ссылка в новой задаче