Skip to content

Commit

Permalink
chore: migrate src/FrameManager to TypeScript (#5773)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfranklin committed Apr 29, 2020
1 parent c5c97b0 commit 8a5008e
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 347 deletions.
11 changes: 6 additions & 5 deletions src/DOMWorld.ts
Expand Up @@ -22,18 +22,19 @@ import {JSHandle, ElementHandle} from './JSHandle';
import {ExecutionContext} from './ExecutionContext';
import {TimeoutSettings} from './TimeoutSettings';
import {MouseButtonInput} from './Input';
import {FrameManager, Frame} from './FrameManager';

const readFileAsync = helper.promisify(fs.readFile);

interface WaitForSelectorOptions {
export interface WaitForSelectorOptions {
visible?: boolean;
hidden?: boolean;
timeout?: number;
}

export class DOMWorld {
_frameManager: Puppeteer.FrameManager;
_frame: Puppeteer.Frame;
_frameManager: FrameManager;
_frame: Frame;
_timeoutSettings: TimeoutSettings;
_documentPromise?: Promise<ElementHandle> = null;
_contextPromise?: Promise<ExecutionContext> = null;
Expand All @@ -43,14 +44,14 @@ export class DOMWorld {
_detached = false;
_waitTasks = new Set<WaitTask>();

constructor(frameManager: Puppeteer.FrameManager, frame: Puppeteer.Frame, timeoutSettings: TimeoutSettings) {
constructor(frameManager: FrameManager, frame: Frame, timeoutSettings: TimeoutSettings) {
this._frameManager = frameManager;
this._frame = frame;
this._timeoutSettings = timeoutSettings;
this._setContext(null);
}

frame(): Puppeteer.Frame {
frame(): Frame {
return this._frame;
}

Expand Down
3 changes: 2 additions & 1 deletion src/ExecutionContext.ts
Expand Up @@ -18,6 +18,7 @@ import {helper, assert} from './helper';
import {createJSHandle, JSHandle, ElementHandle} from './JSHandle';
import {CDPSession} from './Connection';
import {DOMWorld} from './DOMWorld';
import {Frame} from './FrameManager';

export const EVALUATION_SCRIPT_URL = '__puppeteer_evaluation_script__';
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
Expand All @@ -33,7 +34,7 @@ export class ExecutionContext {
this._contextId = contextPayload.id;
}

frame(): Puppeteer.Frame | null {
frame(): Frame | null {
return this._world ? this._world.frame() : null;
}

Expand Down

0 comments on commit 8a5008e

Please sign in to comment.