How to use _onCrashed method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Page.js

Source:Page.js Github

copy

Full Screen

...578 inspect: "检查",579 },580 })581 }582 _onCrashed() {583 this.isCrashed = true584 if (this.$dom) {585 let crashedDOM = document.createElement("div")586 crashedDOM.innerHTML =587 '<div style="width: 100%; position: absolute; left: 0; top: 0; height: 100%; z-index: 2; background: #fff; padding: 100px; font-size: 24px; color: #444; line-height: 32px; "><svg t="1598317803345" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2065" width="32" height="32" style=" margin-right: 20px; display: inline-block; vertical-align: top; "><path d="M1024 519.9872C1024 484.4544 984.9344 0 506.2656 0 79.36 0 0 433.0496 0 522.5984c0 323.2768 298.24 372.8384 298.24 372.8384-16.2304 86.528 43.1616 147.0464 137.3696 103.936 77.056 52.8896 132.352 4.096 132.352 4.096 62.464 34.5088 158.6688-7.1168 145.152-108.9536 0 0 310.8864-63.0784 310.8864-374.4768M299.008 649.216c-78.8992 0-142.8992-75.9808-142.8992-169.7792 0-93.696 64-169.6768 142.848-169.6768 79.0016 0 143.0016 75.9296 143.0016 169.6768 0 93.7984-64 169.8304-142.9504 169.8304m275.7632 87.808c-3.072 58.112-101.7344 77.1072-112.1792 0-1.1264-15.9744 13.568-77.312 56.064-77.312 42.4448 0 58.9824 58.2656 56.1152 77.1584m150.016-87.6544c-78.9504 0-142.9504-76.032-142.9504-169.8304 0-93.696 64-169.6768 143.0016-169.6768 78.9504 0 142.9504 75.9296 142.9504 169.6768 0 93.7984-64 169.8304-142.9504 169.8304" p-id="2066" fill="currentColor"></path></svg>喔唷,崩溃啦!</div>'588 this.$dom.appendChild(crashedDOM)589 } else {590 }591 }592 _onDestroyed() {593 this.isDestroyed = true594 }595 goHome() {596 return this.goto(this.options.startUrl || "about:blank")...

Full Screen

Full Screen

extensionHost.js

Source:extensionHost.js Github

copy

Full Screen

1/*---------------------------------------------------------------------------------------------2 * Copyright (c) Microsoft Corporation. All rights reserved.3 * Licensed under the MIT License. See License.txt in the project root for license information.4 *--------------------------------------------------------------------------------------------*/5var __assign = (this && this.__assign) || Object.assign || function(t) {6 for (var s, i = 1, n = arguments.length; i < n; i++) {7 s = arguments[i];8 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))9 t[p] = s[p];10 }11 return t;12};13var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {14 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;15 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);16 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;17 return c > 3 && r && Object.defineProperty(target, key, r), r;18};19var __param = (this && this.__param) || function (paramIndex, decorator) {20 return function (target, key) { decorator(target, key, paramIndex); }21};22define(["require", "exports", "vs/nls", "vs/base/common/errorMessage", "vs/base/common/objects", "vs/base/common/uri", "vs/base/common/winjs.base", "vs/base/common/platform", "vs/base/node/ports", "vs/platform/message/common/message", "vs/platform/lifecycle/common/lifecycle", "vs/platform/windows/common/windows", "vs/platform/workspace/common/workspace", "vs/platform/telemetry/common/telemetry", "child_process", "electron", "vs/platform/node/product", "vs/platform/environment/common/environment", "vs/base/parts/ipc/node/ipc.net", "net", "vs/base/common/event", "vs/workbench/services/configuration/common/configuration", "vs/workbench/services/crashReporter/electron-browser/crashReporterService", "vs/platform/broadcast/electron-browser/broadcastService", "vs/base/common/paths", "vs/platform/extensions/common/extensionHost", "vs/base/common/lifecycle", "vs/base/node/console", "vs/platform/configuration/common/configurationRegistry", "vs/platform/log/common/log"], function (require, exports, nls, errorMessage_1, objects, uri_1, winjs_base_1, platform_1, ports_1, message_1, lifecycle_1, windows_1, workspace_1, telemetry_1, child_process_1, electron_1, product_1, environment_1, ipc_net_1, net_1, event_1, configuration_1, crashReporterService_1, broadcastService_1, paths_1, extensionHost_1, lifecycle_2, console_1, configurationRegistry_1, log_1) {23 'use strict';24 Object.defineProperty(exports, "__esModule", { value: true });25 var ExtensionHostProcessWorker = /** @class */ (function () {26 function ExtensionHostProcessWorker(27 /* intentionally not injected */ _extensionService, _contextService, _messageService, _windowsService, _windowService, _broadcastService, _lifecycleService, _environmentService, _configurationService, _telemetryService, _crashReporterService, _logService) {28 var _this = this;29 this._extensionService = _extensionService;30 this._contextService = _contextService;31 this._messageService = _messageService;32 this._windowsService = _windowsService;33 this._windowService = _windowService;34 this._broadcastService = _broadcastService;35 this._lifecycleService = _lifecycleService;36 this._environmentService = _environmentService;37 this._configurationService = _configurationService;38 this._telemetryService = _telemetryService;39 this._crashReporterService = _crashReporterService;40 this._logService = _logService;41 this._onCrashed = new event_1.Emitter();42 this.onCrashed = this._onCrashed.event;43 // handle extension host lifecycle a bit special when we know we are developing an extension that runs inside44 this._isExtensionDevHost = this._environmentService.isExtensionDevelopment;45 this._isExtensionDevDebug = (typeof this._environmentService.debugExtensionHost.port === 'number');46 this._isExtensionDevDebugBrk = !!this._environmentService.debugExtensionHost.break;47 this._isExtensionDevTestFromCli = this._isExtensionDevHost && !!this._environmentService.extensionTestsPath && !this._environmentService.debugExtensionHost.break;48 this._lastExtensionHostError = null;49 this._terminating = false;50 this._namedPipeServer = null;51 this._extensionHostProcess = null;52 this._extensionHostConnection = null;53 this._messageProtocol = null;54 this._toDispose = [];55 this._toDispose.push(this._onCrashed);56 this._toDispose.push(this._lifecycleService.onWillShutdown(function (e) { return _this._onWillShutdown(e); }));57 this._toDispose.push(this._lifecycleService.onShutdown(function (reason) { return _this.terminate(); }));58 this._toDispose.push(this._broadcastService.onBroadcast(function (b) { return _this._onBroadcast(b); }));59 var globalExitListener = function () { return _this.terminate(); };60 process.once('exit', globalExitListener);61 this._toDispose.push({62 dispose: function () {63 process.removeListener('exit', globalExitListener);64 }65 });66 }67 ExtensionHostProcessWorker.prototype.dispose = function () {68 this.terminate();69 };70 ExtensionHostProcessWorker.prototype._onBroadcast = function (broadcast) {71 var _this = this;72 // Close Ext Host Window Request73 if (broadcast.channel === extensionHost_1.EXTENSION_CLOSE_EXTHOST_BROADCAST_CHANNEL && this._isExtensionDevHost) {74 var extensionPaths = broadcast.payload;75 if (Array.isArray(extensionPaths) && extensionPaths.some(function (path) { return paths_1.isEqual(_this._environmentService.extensionDevelopmentPath, path, !platform_1.isLinux); })) {76 this._windowService.closeWindow();77 }78 }79 if (broadcast.channel === extensionHost_1.EXTENSION_RELOAD_BROADCAST_CHANNEL && this._isExtensionDevHost) {80 var extensionPaths = broadcast.payload;81 if (Array.isArray(extensionPaths) && extensionPaths.some(function (path) { return paths_1.isEqual(_this._environmentService.extensionDevelopmentPath, path, !platform_1.isLinux); })) {82 this._windowService.reloadWindow();83 }84 }85 };86 ExtensionHostProcessWorker.prototype.start = function () {87 var _this = this;88 if (this._terminating) {89 // .terminate() was called90 return null;91 }92 if (!this._messageProtocol) {93 this._messageProtocol = winjs_base_1.TPromise.join([this._tryListenOnPipe(), this._tryFindDebugPort()]).then(function (data) {94 var pipeName = data[0];95 var portData = data[1];96 var opts = {97 env: objects.mixin(objects.deepClone(process.env), {98 AMD_ENTRYPOINT: 'vs/workbench/node/extensionHostProcess',99 PIPE_LOGGING: 'true',100 VERBOSE_LOGGING: true,101 VSCODE_WINDOW_ID: String(_this._windowService.getCurrentWindowId()),102 VSCODE_IPC_HOOK_EXTHOST: pipeName,103 VSCODE_HANDLES_UNCAUGHT_ERRORS: true,104 VSCODE_LOG_STACK: !_this._isExtensionDevTestFromCli && (_this._isExtensionDevHost || !_this._environmentService.isBuilt || product_1.default.quality !== 'stable' || _this._environmentService.verbose)105 }),106 // We only detach the extension host on windows. Linux and Mac orphan by default107 // and detach under Linux and Mac create another process group.108 // We detach because we have noticed that when the renderer exits, its child processes109 // (i.e. extension host) are taken down in a brutal fashion by the OS110 detached: !!platform_1.isWindows,111 execArgv: undefined,112 silent: true113 };114 if (portData.actual) {115 opts.execArgv = [116 '--nolazy',117 (_this._isExtensionDevDebugBrk ? '--inspect-brk=' : '--inspect=') + portData.actual118 ];119 if (!portData.expected) {120 // No one asked for 'inspect' or 'inspect-brk', only us. We add another121 // option such that the extension host can manipulate the execArgv array122 opts.env.VSCODE_PREVENT_FOREIGN_INSPECT = true;123 }124 }125 var crashReporterOptions = _this._crashReporterService.getChildProcessStartOptions('extensionHost');126 if (crashReporterOptions) {127 opts.env.CRASH_REPORTER_START_OPTIONS = JSON.stringify(crashReporterOptions);128 }129 // Run Extension Host as fork of current process130 _this._extensionHostProcess = child_process_1.fork(uri_1.default.parse(require.toUrl('bootstrap')).fsPath, ['--type=extensionHost'], opts);131 _this._extensionHostProcess.stdout.setEncoding('utf8');132 _this._extensionHostProcess.stderr.setEncoding('utf8');133 var onStdout = event_1.fromNodeEventEmitter(_this._extensionHostProcess.stdout, 'data');134 var onStderr = event_1.fromNodeEventEmitter(_this._extensionHostProcess.stderr, 'data');135 var onOutput = event_1.anyEvent(event_1.mapEvent(onStdout, function (o) { return ({ data: "%c" + o, format: [''] }); }), event_1.mapEvent(onStderr, function (o) { return ({ data: "%c" + o, format: ['color: red'] }); }));136 // Debounce all output, so we can render it in the Chrome console as a group137 var onDebouncedOutput = event_1.debounceEvent(onOutput, function (r, o) {138 return r139 ? { data: r.data + o.data, format: r.format.concat(o.format) }140 : { data: o.data, format: o.format };141 }, 100);142 // Print out extension host output143 onDebouncedOutput(function (data) {144 var inspectorUrlIndex = !_this._environmentService.isBuilt && data.data && data.data.indexOf('chrome-devtools://');145 if (inspectorUrlIndex >= 0) {146 console.log("%c[Extension Host] %cdebugger inspector at " + data.data.substr(inspectorUrlIndex), 'color: blue', 'color: black');147 }148 else {149 console.group('Extension Host');150 console.log.apply(console, [data.data].concat(data.format));151 console.groupEnd();152 }153 });154 // Support logging from extension host155 _this._extensionHostProcess.on('message', function (msg) {156 if (msg && msg.type === '__$console') {157 _this._logExtensionHostMessage(msg);158 }159 });160 // Lifecycle161 _this._extensionHostProcess.on('error', function (err) { return _this._onExtHostProcessError(err); });162 _this._extensionHostProcess.on('exit', function (code, signal) { return _this._onExtHostProcessExit(code, signal); });163 // Notify debugger that we are ready to attach to the process if we run a development extension164 if (_this._isExtensionDevHost && portData.actual) {165 _this._broadcastService.broadcast({166 channel: extensionHost_1.EXTENSION_ATTACH_BROADCAST_CHANNEL,167 payload: {168 debugId: _this._environmentService.debugExtensionHost.debugId,169 port: portData.actual170 }171 });172 }173 _this._inspectPort = portData.actual;174 // Help in case we fail to start it175 var startupTimeoutHandle;176 if (!_this._environmentService.isBuilt || _this._isExtensionDevHost) {177 startupTimeoutHandle = setTimeout(function () {178 var msg = _this._isExtensionDevDebugBrk179 ? nls.localize('extensionHostProcess.startupFailDebug', "Extension host did not start in 10 seconds, it might be stopped on the first line and needs a debugger to continue.")180 : nls.localize('extensionHostProcess.startupFail', "Extension host did not start in 10 seconds, that might be a problem.");181 _this._messageService.show(message_1.Severity.Warning, msg);182 }, 10000);183 }184 // Initialize extension host process with hand shakes185 return _this._tryExtHostHandshake().then(function (protocol) {186 clearTimeout(startupTimeoutHandle);187 return protocol;188 });189 });190 }191 return this._messageProtocol;192 };193 /**194 * Start a server (`this._namedPipeServer`) that listens on a named pipe and return the named pipe name.195 */196 ExtensionHostProcessWorker.prototype._tryListenOnPipe = function () {197 var _this = this;198 return new winjs_base_1.TPromise(function (resolve, reject) {199 var pipeName = ipc_net_1.generateRandomPipeName();200 _this._namedPipeServer = net_1.createServer();201 _this._namedPipeServer.on('error', reject);202 _this._namedPipeServer.listen(pipeName, function () {203 _this._namedPipeServer.removeListener('error', reject);204 resolve(pipeName);205 });206 });207 };208 /**209 * Find a free port if extension host debugging is enabled.210 */211 ExtensionHostProcessWorker.prototype._tryFindDebugPort = function () {212 var _this = this;213 var expected;214 var startPort = 9333;215 if (typeof this._environmentService.debugExtensionHost.port === 'number') {216 startPort = expected = this._environmentService.debugExtensionHost.port;217 }218 else {219 return winjs_base_1.TPromise.as({ expected: undefined, actual: 0 });220 }221 return new winjs_base_1.TPromise(function (c, e) {222 return ports_1.findFreePort(startPort, 10 /* try 10 ports */, 5000 /* try up to 5 seconds */).then(function (port) {223 if (!port) {224 console.warn('%c[Extension Host] %cCould not find a free port for debugging', 'color: blue', 'color: black');225 }226 else {227 if (expected && port !== expected) {228 console.warn("%c[Extension Host] %cProvided debugging port " + expected + " is not free, using " + port + " instead.", 'color: blue', 'color: black');229 }230 if (_this._isExtensionDevDebugBrk) {231 console.warn("%c[Extension Host] %cSTOPPED on first line for debugging on port " + port, 'color: blue', 'color: black');232 }233 else {234 console.info("%c[Extension Host] %cdebugger listening on port " + port, 'color: blue', 'color: black');235 }236 }237 return c({ expected: expected, actual: port });238 });239 });240 };241 ExtensionHostProcessWorker.prototype._tryExtHostHandshake = function () {242 var _this = this;243 return new winjs_base_1.TPromise(function (resolve, reject) {244 // Wait for the extension host to connect to our named pipe245 // and wrap the socket in the message passing protocol246 var handle = setTimeout(function () {247 _this._namedPipeServer.close();248 _this._namedPipeServer = null;249 reject('timeout');250 }, 60 * 1000);251 _this._namedPipeServer.on('connection', function (socket) {252 clearTimeout(handle);253 _this._namedPipeServer.close();254 _this._namedPipeServer = null;255 _this._extensionHostConnection = socket;256 resolve(new ipc_net_1.Protocol(_this._extensionHostConnection));257 });258 }).then(function (protocol) {259 // 1) wait for the incoming `ready` event and send the initialization data.260 // 2) wait for the incoming `initialized` event.261 return new winjs_base_1.TPromise(function (resolve, reject) {262 var handle = setTimeout(function () {263 reject('timeout');264 }, 60 * 1000);265 var disposable = protocol.onMessage(function (msg) {266 if (msg === 'ready') {267 // 1) Extension Host is ready to receive messages, initialize it268 _this._createExtHostInitData().then(function (data) { return protocol.send(JSON.stringify(data)); });269 return;270 }271 if (msg === 'initialized') {272 // 2) Extension Host is initialized273 clearTimeout(handle);274 // stop listening for messages here275 disposable.dispose();276 // release this promise277 resolve(protocol);278 return;279 }280 console.error("received unexpected message during handshake phase from the extension host: ", msg);281 });282 });283 });284 };285 ExtensionHostProcessWorker.prototype._createExtHostInitData = function () {286 var _this = this;287 return winjs_base_1.TPromise.join([this._telemetryService.getTelemetryInfo(), this._extensionService.getExtensions()]).then(function (_a) {288 var telemetryInfo = _a[0], extensionDescriptions = _a[1];289 var configurationData = __assign({}, _this._configurationService.getConfigurationData(), { configurationScopes: {} });290 var r = {291 parentPid: process.pid,292 environment: {293 isExtensionDevelopmentDebug: _this._isExtensionDevDebug,294 appRoot: _this._environmentService.appRoot,295 appSettingsHome: _this._environmentService.appSettingsHome,296 disableExtensions: _this._environmentService.disableExtensions,297 userExtensionsHome: _this._environmentService.extensionsPath,298 extensionDevelopmentPath: _this._environmentService.extensionDevelopmentPath,299 extensionTestsPath: _this._environmentService.extensionTestsPath,300 // globally disable proposed api when built and not insiders developing extensions301 enableProposedApiForAll: !_this._environmentService.isBuilt || (!!_this._environmentService.extensionDevelopmentPath && product_1.default.nameLong.indexOf('Insiders') >= 0),302 enableProposedApiFor: _this._environmentService.args['enable-proposed-api'] || []303 },304 workspace: _this._contextService.getWorkbenchState() === workspace_1.WorkbenchState.EMPTY ? null : _this._contextService.getWorkspace(),305 extensions: extensionDescriptions,306 // Send configurations scopes only in development mode.307 configuration: !_this._environmentService.isBuilt || _this._environmentService.isExtensionDevelopment ? __assign({}, configurationData, { configurationScopes: configurationRegistry_1.getScopes() }) : configurationData,308 telemetryInfo: telemetryInfo,309 args: _this._environmentService.args,310 execPath: _this._environmentService.execPath,311 windowId: _this._windowService.getCurrentWindowId(),312 logLevel: _this._logService.getLevel()313 };314 return r;315 });316 };317 ExtensionHostProcessWorker.prototype._logExtensionHostMessage = function (entry) {318 // Send to local console unless we run tests from cli319 if (!this._isExtensionDevTestFromCli) {320 console_1.log(entry, 'Extension Host');321 }322 // Log on main side if running tests from cli323 if (this._isExtensionDevTestFromCli) {324 (_a = this._windowsService).log.apply(_a, [entry.severity].concat(console_1.parse(entry).args));325 }326 else if (!this._environmentService.isBuilt || this._isExtensionDevHost) {327 this._broadcastService.broadcast({328 channel: extensionHost_1.EXTENSION_LOG_BROADCAST_CHANNEL,329 payload: {330 logEntry: entry,331 debugId: this._environmentService.debugExtensionHost.debugId332 }333 });334 }335 var _a;336 };337 ExtensionHostProcessWorker.prototype._onExtHostProcessError = function (err) {338 var errorMessage = errorMessage_1.toErrorMessage(err);339 if (errorMessage === this._lastExtensionHostError) {340 return; // prevent error spam341 }342 this._lastExtensionHostError = errorMessage;343 this._messageService.show(message_1.Severity.Error, nls.localize('extensionHostProcess.error', "Error from the extension host: {0}", errorMessage));344 };345 ExtensionHostProcessWorker.prototype._onExtHostProcessExit = function (code, signal) {346 if (this._terminating) {347 // Expected termination path (we asked the process to terminate)348 return;349 }350 // Unexpected termination351 if (!this._isExtensionDevHost) {352 this._onCrashed.fire([code, signal]);353 }354 else if (!this._isExtensionDevTestFromCli) {355 this._windowService.closeWindow();356 }357 else {358 electron_1.ipcRenderer.send('vscode:exit', code);359 }360 };361 ExtensionHostProcessWorker.prototype.getInspectPort = function () {362 return this._inspectPort;363 };364 ExtensionHostProcessWorker.prototype.terminate = function () {365 var _this = this;366 if (this._terminating) {367 return;368 }369 this._terminating = true;370 lifecycle_2.dispose(this._toDispose);371 if (!this._messageProtocol) {372 // .start() was not called373 return;374 }375 this._messageProtocol.then(function (protocol) {376 // Send the extension host a request to terminate itself377 // (graceful termination)378 protocol.send({379 type: '__$terminate'380 });381 // Give the extension host 60s, after which we will382 // try to kill the process and release any resources383 setTimeout(function () { return _this._cleanResources(); }, 60 * 1000);384 }, function (err) {385 // Establishing a protocol with the extension host failed, so386 // try to kill the process and release any resources.387 _this._cleanResources();388 });389 };390 ExtensionHostProcessWorker.prototype._cleanResources = function () {391 if (this._namedPipeServer) {392 this._namedPipeServer.close();393 this._namedPipeServer = null;394 }395 if (this._extensionHostConnection) {396 this._extensionHostConnection.end();397 this._extensionHostConnection = null;398 }399 if (this._extensionHostProcess) {400 this._extensionHostProcess.kill();401 this._extensionHostProcess = null;402 }403 };404 ExtensionHostProcessWorker.prototype._onWillShutdown = function (event) {405 // If the extension development host was started without debugger attached we need406 // to communicate this back to the main side to terminate the debug session407 if (this._isExtensionDevHost && !this._isExtensionDevTestFromCli && !this._isExtensionDevDebug) {408 this._broadcastService.broadcast({409 channel: extensionHost_1.EXTENSION_TERMINATE_BROADCAST_CHANNEL,410 payload: {411 debugId: this._environmentService.debugExtensionHost.debugId412 }413 });414 event.veto(winjs_base_1.TPromise.timeout(100 /* wait a bit for IPC to get delivered */).then(function () { return false; }));415 }416 };417 ExtensionHostProcessWorker = __decorate([418 __param(1, workspace_1.IWorkspaceContextService),419 __param(2, message_1.IMessageService),420 __param(3, windows_1.IWindowsService),421 __param(4, windows_1.IWindowService),422 __param(5, broadcastService_1.IBroadcastService),423 __param(6, lifecycle_1.ILifecycleService),424 __param(7, environment_1.IEnvironmentService),425 __param(8, configuration_1.IWorkspaceConfigurationService),426 __param(9, telemetry_1.ITelemetryService),427 __param(10, crashReporterService_1.ICrashReporterService),428 __param(11, log_1.ILogService)429 ], ExtensionHostProcessWorker);430 return ExtensionHostProcessWorker;431 }());432 exports.ExtensionHostProcessWorker = ExtensionHostProcessWorker; ...

Full Screen

Full Screen

ffPage.js

Source:ffPage.js Github

copy

Full Screen

...271 const worker = this._workers.get(event.workerId);272 if (!worker) return;273 worker.session.dispatchMessage(JSON.parse(event.message));274 }275 async _onCrashed(event) {276 this._session.markAsCrashed();277 this._page._didCrash();278 }279 _onVideoRecordingStarted(event) {280 this._browserContext._browser._videoStarted(this._browserContext, event.screencastId, event.file, this.pageOrError());281 }282 async exposeBinding(binding) {283 await this._session.send('Page.addBinding', {284 name: binding.name,285 script: binding.source286 });287 }288 didClose() {289 this._session.dispose();...

Full Screen

Full Screen

servant.js

Source:servant.js Github

copy

Full Screen

1/*!---------------------------------------------------------2* Copyright (C) Microsoft Corporation. All rights reserved.3*--------------------------------------------------------*/4/// <reference path="./declare/node.d.ts" />5/// <reference path="./declare/atom-browser.d.ts" />6'use strict';7var BrowserWindow = require('browser-window');8var env = require('./env');9var ManagedBrowserWindow = (function () {10 function ManagedBrowserWindow(opts, owner, onDisposedCallback) {11 var _this = this;12 this.id = String(++ManagedBrowserWindow.INSTANCE_COUNT);13 this.owner = owner;14 this._onDisposedCallback = onDisposedCallback;15 this.masterProcessId = opts.pid;16 this.masterRequestId = opts.reqId;17 var bounds = require('screen').getPrimaryDisplay().bounds;18 this.browserWindow = new BrowserWindow({19 x: 10 + bounds.x + (ManagedBrowserWindow.INSTANCE_COUNT * 50) % Math.floor(bounds.width / 2),20 y: 10 + bounds.y + (ManagedBrowserWindow.INSTANCE_COUNT * 50) % Math.floor(bounds.height / 2),21 width: 800,22 height: 600,23 show: false,24 frame: true,25 kiosk: false26 });27 this.browserWindow.setTitle(opts.name);28 this._onFrameFinishLoad = function () {29 _this.postMessage({30 $tbw: true,31 ownerProcessId: _this.masterProcessId,32 communicationId: _this.id,33 appRoot: env.appRoot,34 module: opts.module,35 initData: opts.initData36 });37 _this.owner.send('ticino:servant:opened', {38 reqId: _this.masterRequestId,39 id: _this.id40 });41 };42 this.browserWindow.webContents.on('did-frame-finish-load', this._onFrameFinishLoad);43 this.browserWindow.loadUrl('file://' + __dirname.replace(/\\/g, '/') + '/index-servant.html');44 this._onCrashed = function () {45 try {46 _this.owner.send('ticino:servant:crashed', {47 $tbw_id: _this.id48 });49 }50 catch (e) {51 console.warn('Could not notify owner that managed browser process crashed: ', e);52 }53 _this._dispose(true);54 };55 this.browserWindow.webContents.on('crashed', this._onCrashed);56 }57 ManagedBrowserWindow.prototype._dispose = function (isCrash) {58 try {59 this.browserWindow.webContents.removeAllListeners();60 }61 catch (e) {62 console.warn('Could not remove all listeners from managed browser process: ', e);63 }64 try {65 this.browserWindow.destroy();66 }67 catch (e) {68 console.warn('Could not destroy managed browser process: ', e);69 }70 this.id = null;71 this.masterProcessId = -1;72 this.masterRequestId = -1;73 this.browserWindow = null;74 this.owner = null;75 this._onFrameFinishLoad = null;76 this._onCrashed = null;77 var onDisposed = this._onDisposedCallback;78 this._onDisposedCallback = null;79 onDisposed();80 };81 ManagedBrowserWindow.prototype.dispose = function () {82 this._dispose(false);83 };84 ManagedBrowserWindow.prototype.getId = function () {85 return this.id;86 };87 ManagedBrowserWindow.prototype.postMessage = function (msg) {88 if (this.browserWindow.webContents) {89 this.browserWindow.webContents.send('tbw', msg);90 }91 else {92 console.warn('Cannot send message to managed browser window (because [I am]|[it is] shutting down?)');93 }94 };95 ManagedBrowserWindow.prototype.sendMessageToOwner = function (msg) {96 this.owner.send('tbw', msg);97 };98 ManagedBrowserWindow.prototype.reveal = function () {99 this.browserWindow.openDevTools();100 this.browserWindow.show();101 };102 ManagedBrowserWindow.prototype.hide = function () {103 this.browserWindow.closeDevTools();104 this.browserWindow.hide();105 };106 ManagedBrowserWindow.INSTANCE_COUNT = 0;107 return ManagedBrowserWindow;108})(); ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: `example.png` });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: `example.png` });15 await browser._onCrashed();16 await browser.close();17})();18 at processTicksAndRejections (internal/process/task_queues.js:93:5)19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page._onCrashed();6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 await page._onCrashed();13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 await page._onCrashed();20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const page = await browser.newPage();26 await page._onCrashed();27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 await page._onCrashed();34 await browser.close();35})();36const { chromium } = require('playwright');37(async () => {38 const browser = await chromium.launch();39 const page = await browser.newPage();40 await page._onCrashed();41 await browser.close();42})();43const { chromium } = require('playwright');44(async () => {45 const browser = await chromium.launch();46 const page = await browser.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const page = await browser.newPage();5 await page._onCrashed();6 await browser.close();7})();8 at Page._onCrashed (C:\Users\user\playwright\test.js:8:24)9 at processTicksAndRejections (internal/process/task_queues.js:97:5)10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const page = await browser.newPage();14 const url = await page.url();15 console.log(url);16 await browser.close();17})();18const { chromium } = require('playwright');19(async () => {20 const browser = await chromium.launch();21 const page = await browser.newPage();22 const url = await page.url();23 console.log(url);24 await browser.close();25})();26const { chromium } = require('playwright');27(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { _onCrashed } = require('playwright/lib/server/crBrowser');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 _onCrashed(page, 'crashed');8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async() => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.evaluate(() => {6 document.querySelector('body').innerHTML = '<iframe></iframe>';7 });8 await page._onCrashed();9 await browser.close();10})();11 at Frame._onCrashed (C:\Users\abc\playwright\playwright\lib\server\frame.js:119:15)12 at Page._onCrashed (C:\Users\abc\playwright\playwright\lib\server\page.js:105:23)13 at Object.onCrashed (C:\Users\abc\playwright\playwright\lib\server\chromium\crBrowser.js:34:24)14 at CDPSession.emit (events.js:315:20)15 at CDPSession._onMessage (C:\Users\abc\playwright\playwright\lib\server\cdpsession.js:94:10)16 at WebSocketTransport._ws.addEventListener.event (C:\Users\abc\playwright\playwright\lib\server\webSocketTransport.js:32:24)17 at WebSocket.onMessage (C:\Users\abc\playwright\playwright\lib\server\webSocket.js:99:14)18 at WebSocket.emit (events.js:315:20)19 at Receiver.receiverOnMessage (C:\Users\abc\playwright\playwright\node_modules\ws\lib\websocket.js:800:20)20 at Receiver.emit (events.js:315:20)

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { _onCrashed } = require('playwright/lib/server/browserServer');3(async () => {4 const browser = await playwright['chromium'].launch();5 const page = await browser.newPage();6 await browser.close();7 _onCrashed();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _onCrashed } = require('playwright/lib/server/chromium/crBrowser');2_onCrashed.call(browser, 'Crashed');3const { _onClosed } = require('playwright/lib/server/chromium/crBrowser');4_onClosed.call(browser, 'Closed');5const { _onDisconnected } = require('playwright/lib/server/chromium/crBrowser');6_onDisconnected.call(browser, 'Disconnected');7const { _onTargetCrashed } = require('playwright/lib/server/chromium/crBrowser');8_onTargetCrashed.call(browser, 'TargetCrashed', 'TargetCrashed');9const { _onTargetDestroyed } = require('playwright/lib/server/chromium/crBrowser');10_onTargetDestroyed.call(browser, 'TargetDestroyed', 'TargetDestroyed');11const { _onTargetChanged } = require('playwright/lib/server/chromium/crBrowser');12_onTargetChanged.call(browser, 'TargetChanged', 'TargetChanged');13const { _onTargetCreated } = require('playwright/lib/server/chromium/crBrowser');14_onTargetCreated.call(browser, 'TargetCreated', 'TargetCreated');15const { _onTargetDetached } = require('playwright/lib/server/chromium/crBrowser');16_onTargetDetached.call(browser, 'TargetDetached', 'TargetDetached');17const { _onTargetAttached } = require('playwright/lib/server/chromium/crBrowser');18_onTargetAttached.call(browser, 'TargetAttached', 'TargetAttached');19const { _onTargetInfoChanged } = require('playwright/lib/server/chromium/crBrowser');20_onTargetInfoChanged.call(browser, 'TargetInfoChanged', 'TargetInfoChanged');21const { _onTargetDestroyed } = require('playwright

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { _onCrashed } = require('playwright/lib/server/browserType');3const { BrowserType } = require('playwright/lib/server/browserType');4const browserType = playwright.chromium;5_onCrashed.call(browserType, () => {6 console.log('crashed');7});8const playwright = require('playwright');9const { _onCrashed } = require('playwright/lib/server/browserType');10const { BrowserType } = require('playwright/lib/server/browserType');11const browserType = playwright.chromium;12_onCrashed.call(browserType, () => {13 console.log('crashed');14});15const playwright = require('playwright');16const { _onCrashed } = require('playwright/lib/server/browserType');17const { BrowserType } = require('playwright/lib/server/browserType');18const browserType = playwright.chromium;19_onCrashed.call(browserType, () => {20 console.log('crashed');21});22const playwright = require('playwright');23const { _onCrashed } = require('playwright/lib/server/browserType');24const { BrowserType } = require('playwright/lib/server/browserType');25const browserType = playwright.chromium;26_onCrashed.call(browserType, () => {27 console.log('crashed');28});29const playwright = require('playwright');30const { _onCrashed } = require('playwright/lib/server/browserType');31const { BrowserType } = require('playwright/lib/server/browserType');32const browserType = playwright.chromium;33_onCrashed.call(browserType, () => {34 console.log('crashed');35});36const playwright = require('playwright');37const { _onCrashed } = require('playwright/lib/server/browserType');38const { BrowserType } = require('playwright/lib/server/browserType');39const browserType = playwright.chromium;40_onCrashed.call(browserType, () => {41 console.log('crashed');42});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _onCrashed } = require('playwright/lib/server/crBrowser');2const { BrowserContext } = require('playwright/lib/server/browserContext');3const { Browser } = require('playwright/lib/server/browser');4const browser = await Browser.connect({5});6const context = await browser.newContext();7const page = await context.newPage();8await page.evaluate(() => {9 window.crash();10});11_onCrashed.call(context, new Error('test'));12await browser.close();13const { _onCrashed } = require('playwright/lib/server/crBrowser');14const { BrowserContext } = require('playwright/lib/server/browserContext');15const { Browser } = require('playwright/lib/server/browser');16const browser = await Browser.connect({17});18const context = await browser.newContext();19const page = await context.newPage();20await page.evaluate(() => {21 window.crash();22});23_onCrashed.call(context, new Error('test'));24await browser.close();25const { _onCrashed } = require('playwright/lib/server/crBrowser');26const { BrowserContext } = require('playwright/lib/server/browserContext');27const { Browser } = require('playwright/lib/server/browser');28const browser = await Browser.connect({

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful