Skip to content

Commit 30ddc7f

Browse files
author
rocketraccoon
committed
fix(testplane): fix ff and add logs
1 parent 9624f8c commit 30ddc7f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/browser/commands/restoreState/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import fs from "fs-extra";
2+
import _ from "lodash";
23

34
import { clearAllIndexedDB } from "./clearAllIndexedDB";
45
import { restoreIndexedDB } from "./restoreIndexedDB";
56
import { restoreStorage } from "./restoreStorage";
67

7-
import _ from "lodash";
8+
import * as logger from "../../../utils/logger";
89
import type { Browser } from "../../types";
910
import { DEVTOOLS_PROTOCOL, WEBDRIVER_PROTOCOL } from "../../../constants/config";
1011
import { defaultOptions, getWebdriverFrames, SaveStateData, SaveStateOptions } from "../saveState";
1112
import { Protocol } from "devtools-protocol";
1213

13-
type RestoreStateOptions = SaveStateOptions;
14-
1514
export default (browser: Browser): void => {
1615
const { publicAPI: session } = browser;
1716

18-
session.addCommand("restoreState", async (_options: RestoreStateOptions) => {
17+
session.addCommand("restoreState", async (_options: SaveStateOptions) => {
1918
const options = { ...defaultOptions, ..._options };
2019

2120
const restoreState: SaveStateData = await fs.readJson(options.path);
2221

22+
logger.log("Restore state", options);
23+
2324
switch (browser.config.automationProtocol) {
2425
case WEBDRIVER_PROTOCOL: {
2526
if (restoreState.cookies && options.cookies) {
@@ -126,5 +127,7 @@ export default (browser: Browser): void => {
126127
break;
127128
}
128129
}
130+
131+
logger.log("State restored");
129132
});
130133
};

src/browser/commands/saveState/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs-extra";
22

3+
import * as logger from "../../../utils/logger";
34
import type { Browser } from "../../types";
45
import { DumpIndexDB, dumpIndexedDB } from "./dumpIndexedDB";
56
import { dumpStorage, StorageData } from "./dumpStorage";
@@ -48,6 +49,8 @@ export default (browser: Browser): void => {
4849
framesData: {},
4950
};
5051

52+
logger.log("Save state", options);
53+
5154
switch (browser.config.automationProtocol) {
5255
case WEBDRIVER_PROTOCOL: {
5356
if (options.cookies) {
@@ -165,6 +168,7 @@ export default (browser: Browser): void => {
165168
}
166169

167170
if (options && options.path) {
171+
logger.log("State saved");
168172
await fs.writeJson(options.path, data, { spaces: 2 });
169173
}
170174
});

src/browser/existing-browser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Camera, PageMeta } from "./camera";
1010
import { type ClientBridge, build as buildClientBridge } from "./client-bridge";
1111
import * as history from "./history";
1212
import * as logger from "../utils/logger";
13-
import { WEBDRIVER_PROTOCOL } from "../constants/config";
13+
import { DEVTOOLS_PROTOCOL, WEBDRIVER_PROTOCOL } from "../constants/config";
1414
import { MIN_CHROME_VERSION_SUPPORT_ISOLATION } from "../constants/browser";
1515
import { isSupportIsolation } from "../utils/browser";
1616
import { isRunInNodeJsEnv } from "../utils/config";
@@ -98,7 +98,9 @@ export class ExistingBrowser extends Browser {
9898

9999
await isolationPromise;
100100

101-
await this.startCollectCookies();
101+
if (this.config.automationProtocol === DEVTOOLS_PROTOCOL) {
102+
await this.startCollectCookies();
103+
}
102104

103105
this._callstackHistory?.clear();
104106

0 commit comments

Comments
 (0)