Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(agent): in page nav on unload (#77)
Browse files Browse the repository at this point in the history
chore: update typescript
  • Loading branch information
blakebyrnes authored Jan 29, 2024
1 parent 254a2fa commit f248891
Show file tree
Hide file tree
Showing 17 changed files with 13,705 additions and 9,355 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ lerna-debug.log

.idea/
.history/
.yarn/
.vscode/

build
Expand Down
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion agent/main/errors/BrowserLaunchError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class BrowserLaunchError extends Error {
constructor(message: string, stack: string, public isSandboxError: boolean = false) {
constructor(message: string, stack: string, public isSandboxError = false) {
super(message);
stack ??= this.stack;
if (stack.startsWith('Error: ')) stack = stack.substring('Error: '.length);
Expand Down
2 changes: 1 addition & 1 deletion agent/main/lib/BrowserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default class BrowserContext

createTargetPromise.resolve();
const idx = this.creatingTargetPromises.indexOf(createTargetPromise.promise);
if (idx >= 0) this.creatingTargetPromises.splice(idx, 1);
if (idx >= 0) void this.creatingTargetPromises.splice(idx, 1);

let page = this.pagesById.get(targetId);
if (!page) {
Expand Down
33 changes: 23 additions & 10 deletions agent/main/lib/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ export default class Frame extends TypedEventEmitter<IFrameEvents> implements IF
/////// NAVIGATION ///////////////////////////////////////////////////////////////////////////////////////////////////

public initiateNavigation(url: string, loaderId: string): void {
this.waitTimeouts.length = 0;
this.defaultContextCreated = null;
// chain current listeners to new promise
this.setLoader(loaderId, url);
}
Expand Down Expand Up @@ -609,24 +611,35 @@ export default class Frame extends TypedEventEmitter<IFrameEvents> implements IF
if (this.url === url) return;
// we're using params on about:blank, so make sure to strip for url
if (url.startsWith(DEFAULT_PAGE)) url = DEFAULT_PAGE;
this.url = url;

const isDomLoaded = this.activeLoader?.lifecycle?.DOMContentLoaded;
let isForActiveDomain = false;
if (this.activeLoader) {
try {
const previousUrl = new URL(this.activeLoader.url);
if (url.startsWith(previousUrl.origin)) {
isForActiveDomain = true;
}
} catch {}
}
this.url = url;

const isDomLoaded = isForActiveDomain && this.activeLoader?.lifecycle?.DOMContentLoaded;
const loaderId = `${InPageNavigationLoaderPrefix}${(this.inPageCounter += 1)}`;
this.setLoader(loaderId, url);
if (isDomLoaded) {
this.activeLoader.markLoaded();
}

// set load state back to all loaded
this.navigations.onNavigationRequested(
'inPage',
this.url,
this.page.browserContext.commandMarker.lastId,
loaderId,
);
this.emit('frame-navigated', { frame: this, navigatedInDocument: true, loaderId });
if (isForActiveDomain) {
// set load state back to all loaded
this.navigations.onNavigationRequested(
'inPage',
this.url,
this.page.browserContext.commandMarker.lastId,
loaderId,
);
this.emit('frame-navigated', { frame: this, navigatedInDocument: true, loaderId });
}
}

/////// LIFECYCLE ////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
48 changes: 40 additions & 8 deletions agent/main/lib/FrameNavigations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ export default class FrameNavigations
loaderId: string,
browserRequestId?: string,
): INavigation {
let isNewTop = true;
// if in page, make sure we're on the domain of the active url
if (reason === "inPage" && this.currentUrl) {
isNewTop = isSameOrigin(url, this.currentUrl);
}

let nextTop: INavigation;
if (this.currentUrl === url && this.top.loaderId === 'NO_LOADER_ASSIGNED') {
nextTop = this.top;
Expand All @@ -142,11 +148,18 @@ export default class FrameNavigations
resourceIdResolvable: createPromise(),
browserRequestId,
};
nextTop.resourceIdResolvable.promise
.then(this.resolveResourceId.bind(this, nextTop))
.catch(() => null);
this.history.push(nextTop);
this.historyById[nextTop.id] = nextTop;

if (isNewTop) {
nextTop.resourceIdResolvable.promise
.then(this.resolveResourceId.bind(this, nextTop))
.catch(() => null);
this.history.push(nextTop);
} else {
// insert at 1 before last
const index = this.history.length - 1;
this.history.splice(index, 0, nextTop);
}
}
if (loaderId) this.historyByLoaderId[loaderId] = nextTop;

Expand All @@ -161,7 +174,14 @@ export default class FrameNavigations
// if in-page, set the state to match current top
if (reason === 'inPage') {
if (this.top?.finalUrl === url) return;
const lastHttpResponse = this.lastHttpNavigationRequest;
let lastHttpResponse = this.lastHttpNavigationRequest;
if (!isNewTop) {
lastHttpResponse = this.findMostRecentHistory(
x =>
x.navigationReason === 'goto' &&
x.statusChanges.has(LoadStatus.HttpResponded) && isSameOrigin(url, x.finalUrl ?? x.requestedUrl),
);
}
if (lastHttpResponse) {
for (const state of lastHttpResponse.statusChanges.keys()) {
if (isPageLoadedStatus(state)) {
Expand All @@ -174,7 +194,7 @@ export default class FrameNavigations
nextTop.statusChanges.set(ContentPaint, nextTop.initiatedTime);
nextTop.resourceIdResolvable.resolve(-1);
}
shouldPublishLocationChange = true;
shouldPublishLocationChange = isNewTop;
nextTop.finalUrl = url;
} else {
let isStillSameHttpPage = false;
Expand All @@ -190,8 +210,10 @@ export default class FrameNavigations
}
}

this.emit('navigation-requested', nextTop);
this.emit('change', { navigation: nextTop });
if (isNewTop) {
this.emit('navigation-requested', nextTop);
this.emit('change', { navigation: nextTop });
}
if (shouldPublishLocationChange) {
this.emit('status-change', {
id: nextTop.id,
Expand Down Expand Up @@ -504,3 +526,13 @@ function isPageLoadedStatus(status: NavigationStatus): boolean {
status === LoadStatus.DomContentLoaded
);
}

function isSameOrigin(url1: string, url2: string): boolean {
try {
const parsed1 = new URL(url1);
const parsed2 = new URL(url2);
return parsed1.origin === parsed2.origin;
} catch (err) {
return false;
}
}
2 changes: 1 addition & 1 deletion agent/main/test/Mouse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('Mouse', () => {
// Firefox needs an extra frame here after typing or it will fail to set the scrollTop
await page.evaluate(`new Promise(requestAnimationFrame)`);
await page.evaluate(`(document.querySelector('textarea').scrollTop = 0)`);
const { x, y } = await page.evaluate(textareaDimensions);
const { x, y } = await page.evaluate<any>(textareaDimensions);
await page.mouse.move(x + 2, y + 2);
await page.mouse.down();
await page.mouse.move(200, 200);
Expand Down
6 changes: 3 additions & 3 deletions agent/main/test/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ describe('Pages', () => {
<div style="height: 200px; width: 100px; background:red">&nbsp;</div>`,
);
const screenshot = await page.screenshot({ format: 'png' });
expect(screenshot.toString('base64')).toBe(
'iVBORw0KGgoAAAANSUhEUgAABAAAAAOECAYAAAA/m0PDAAAAAXNSR0IArs4c6QAAFjhJREFUeJzt2rENw0AMBEG9of5bpkuQEulh70zM4OIF18zMAQAAAPy1z+4BAAAAwPMEAAAAAAgQAAAAACBAAAAAAIAAAQAAAAACBAAAAAAIEAAAAAAg4Lw6WOuNGQDAk2Z2LwAAdvMBAAAAAAECAAAAAAQIAAAAABAgAAAAAECAAAAAAAABAgAAAAAECAAAAAAQIAAAAABAgAAAAAAAAQIAAAAABAgAAAAAECAAAAAAQIAAAAAAAAECAAAAAAQIAAAAABAgAAAAAECAAAAAAAABAgAAAAAECAAAAAAQIAAAAABAgAAAAAAAAQIAAAAABAgAAAAAECAAAAAAQIAAAAAAAAECAAAAAAQIAAAAABAgAAAAAECAAAAAAAABAgAAAAAECAAAAAAQIAAAAABAgAAAAAAAAQIAAAAABAgAAAAAECAAAAAAQIAAAAAAAAECAAAAAAQIAAAAABAgAAAAAECAAAAAAAABAgAAAAAECAAAAAAQIAAAAABAgAAAAAAAAQIAAAAABAgAAAAAECAAAAAAQIAAAAAAAAECAAAAAAQIAAAAABAgAAAAAECAAAAAAAABAgAAAAAECAAAAAAQIAAAAABAgAAAAAAAAQIAAAAABAgAAAAAECAAAAAAQIAAAAAAAAECAAAAAAQIAAAAABAgAAAAAEC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AAAACBAAAAAAIEAAAAAAgAABAAAAAAIEAAAAAAgQAAAAACBAAAAAAIAAAQAAAAACBAAAAAAIEAAAAAAgQAAAAACAAAEAAAAAAgQAAAAACBAAAAAAIEAAAAAAgAABAAAAAAIEAAAAAAgQAAAAACBAAAAAAIAAAQAAAAACBAAAAAAIEAAAAAAgQAAAAACAAAEAAAAAAgQAAAAACBAAAAAAIEAAAAAAgAABAAAAAAIEAAAAAAgQAAAAACBAAAAAAIAAAQAAAAACBAAAAAAIEAAAAAAg4AuYDhIGVCsWEQAAAABJRU5ErkJggg==',
expect(screenshot.toString('base64')).toContain(
'iVBORw0KGgoAAAANSUhEUgAABAAAAAOECAYAAAA/m0PDAAAAAXNSR0IArs4c6QAAFjhJREFUeJzt2rENw0AMBEG9of5bpkuQEulh70zM4OIF18zMAQAAAPy1z+4BAAAAwPMEAAAAAAgQAAAAACBAAAAAAIAA',
);
});

Expand Down Expand Up @@ -239,7 +239,7 @@ describe('Pages', () => {
},
});
expect(screenshot.toString('base64')).toContain(
'ANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANAgKADQICgA0CAoANA',
'iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAAAXNSR0IArs4c6QAAB',
);
});

Expand Down
2 changes: 2 additions & 0 deletions alsoCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ void (async () => {
'double-agent/collect/certs/*',
'double-agent/**/.env*',
'agent/testing/certs/*.pem',
".yarn/*",
".yarnrc.yml",
'-a',
`${__dirname}/build`,
],
Expand Down
2 changes: 1 addition & 1 deletion package.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
},
"devDependencies": {
"jest": "^29.5.0",
"cross-env": "^7.0.2"
"cross-env": "^7.0.3"
}
}
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,30 @@
"@commitlint/config-conventional": "^17.6.3",
"@types/jest": "^29.5.1",
"@types/node": "^16.18.31",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@ulixee/repo-tools": "^1.0.26",
"concurrently": "^6.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-monorepo-cop": "^1.0.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"lerna": "^4.0.0",
"lint-staged": "^13.2.2",
"prettier": "^3.2.4",
"shx": "^0.3.3",
"typescript": "~4.7.3"
"typescript": "~5.3.3"
},
"workspaces": {
"packages": [
Expand All @@ -61,8 +76,7 @@
"browser-profiler/*",
"browser-emulator-builder",
"../shared/build/*"
],
"nohoist": []
]
},
"lint-staged": {
"*.ts": [
Expand Down
2 changes: 1 addition & 1 deletion plugins/default-browser-emulator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import UserAgentOptions from './lib/UserAgentOptions';
import BrowserEngineOptions from './lib/BrowserEngineOptions';

// Configuration to rotate out the default browser id. Used for testing different browsers via cli
const defaultBrowserId = process.env.ULX_DEFAULT_BROWSER_ID ?? process.env.ULX_DEFAULT_BROWSER_ID;
const defaultBrowserId = process.env.ULX_DEFAULT_BROWSER_ID;

const dataLoader = new DataLoader();
const browserEngineOptions = new BrowserEngineOptions(dataLoader, defaultBrowserId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ if ('webdriver' in self.navigator) {
}

if ('NetworkInformation' in self) {
proxyGetter(self.NetworkInformation.prototype as any, 'rtt', () => args.rtt, false);
proxyGetter((self.NetworkInformation as any).prototype as any, 'rtt', () => args.rtt, false);
}

if (args.userAgentData && 'userAgentData' in self.navigator) {
// @ts-expect-error
const userAgentData = self.navigator.userAgentData;
const userAgentData = self.navigator.userAgentData as any;
function checkThisArg(thisArg, customMessage = ''): TypeError {
// @ts-expect-error
if (Object.getPrototypeOf(thisArg) !== self.NavigatorUAData.prototype) {
Expand Down
Loading

0 comments on commit f248891

Please sign in to comment.