From 97637036c1376bdd7b83515f9db1bef473cf7a51 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Wed, 24 Apr 2024 13:40:42 +0200 Subject: [PATCH] test: change test for BrowserContext (#12321) --- test/TestExpectations.json | 107 ++++++++++++++++---------------- test/src/browsercontext.spec.ts | 12 ++-- 2 files changed, 61 insertions(+), 58 deletions(-) diff --git a/test/TestExpectations.json b/test/TestExpectations.json index fa172f31be2..b833bdd6365 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -202,55 +202,6 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, - { - "testIdPattern": "[browsercontext.spec] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"], - "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should be prompt by default", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext should close all belonging targets once closing context", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext should create new incognito context", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext should have default context", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext should timeout waiting for a non-existent target", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext should wait for a target", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[browsercontext.spec] BrowserContext window.open should use parent tab context", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, { "testIdPattern": "[CDPSession.spec] Target.createCDPSession *", "platforms": ["darwin", "linux", "win32"], @@ -1001,10 +952,11 @@ "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, { - "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should fail when bad permission is given", + "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should deny permission when not listed", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["PASS"] + "expectations": ["FAIL"], + "comment": "Firefox does not have support for the Permissions BiDi extension yet" }, { "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should grant permission when listed", @@ -1013,6 +965,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should grant permission when listed", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["FAIL"], + "comment": "Firefox does not have support for the Permissions BiDi extension yet" + }, { "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should grant persistent-storage", "platforms": ["darwin", "linux", "win32"], @@ -1020,6 +979,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should grant persistent-storage", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["FAIL"], + "comment": "Firefox does not have support for the Permissions BiDi extension yet" + }, { "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should isolate permissions between browser contexts", "platforms": ["darwin", "linux", "win32"], @@ -1027,6 +993,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should isolate permissions between browser contexts", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["FAIL"], + "comment": "Firefox does not have support for the Permissions BiDi extension yet" + }, { "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should reset permissions", "platforms": ["darwin", "linux", "win32"], @@ -1034,12 +1007,26 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should reset permissions", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["FAIL"], + "comment": "Firefox does not have support for the Permissions BiDi extension yet" + }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should trigger permission onchange", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["cdp", "firefox"], + "expectations": ["FAIL"], + "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" + }, { "testIdPattern": "[browsercontext.spec] BrowserContext BrowserContext.overridePermissions should trigger permission onchange", "platforms": ["darwin", "linux", "win32"], - "parameters": ["cdp", "firefox"], + "parameters": ["firefox", "webDriverBiDi"], "expectations": ["FAIL"], - "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" + "comment": "Firefox does not have support for the Permissions BiDi extension yet" }, { "testIdPattern": "[browsercontext.spec] BrowserContext should fire target events", @@ -1055,6 +1042,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext should fire target events", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["FAIL"], + "comment": "In BiDi currently more events than needed are fired (because target is updated more often). We probably need to adjust the test as the behavior is not broken per se" + }, { "testIdPattern": "[browsercontext.spec] BrowserContext should wait for a target", "platforms": ["darwin", "linux", "win32"], @@ -1069,6 +1063,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[browsercontext.spec] BrowserContext should work across sessions", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["FAIL"], + "comment": "Firefox does not support multiple connection at this time" + }, { "testIdPattern": "[CDPSession.spec] Target.createCDPSession should be able to detach session", "platforms": ["darwin", "linux", "win32"], diff --git a/test/src/browsercontext.spec.ts b/test/src/browsercontext.spec.ts index 27709e90bf7..66ddaeb1837 100644 --- a/test/src/browsercontext.spec.ts +++ b/test/src/browsercontext.spec.ts @@ -155,6 +155,7 @@ describe('BrowserContext', function () { skipContextCreation: true, }); + const contextCount = browser.browserContexts().length; // Create two incognito contexts. const context1 = await browser.createBrowserContext(); const context2 = await browser.createBrowserContext(); @@ -209,7 +210,7 @@ describe('BrowserContext', function () { // Cleanup contexts. await Promise.all([context1.close(), context2.close()]); - expect(browser.browserContexts()).toHaveLength(1); + expect(browser.browserContexts()).toHaveLength(contextCount); }); it('should work across sessions', async () => { @@ -238,12 +239,13 @@ describe('BrowserContext', function () { skipContextCreation: true, }); - expect(browser.browserContexts()).toHaveLength(1); - expect(browser.browserContexts()[0]!.id).toBeUndefined(); + const contextCount = browser.browserContexts().length; + + expect(contextCount).toBeGreaterThanOrEqual(1); const context = await browser.createBrowserContext(); - expect(browser.browserContexts()).toHaveLength(2); - expect(browser.browserContexts()[1]!.id).toBeDefined(); + expect(browser.browserContexts()).toHaveLength(contextCount + 1); + expect(context.id).toBeDefined(); await context.close(); });