How to use waitForCrash method in root

Best JavaScript code snippet using root

api-crash-reporter-spec.ts

Source:api-crash-reporter-spec.ts Github

copy

Full Screen

...127 describe('should send minidump', () => {128 it('when renderer crashes', async () => {129 const { port, waitForCrash } = await startServer();130 runCrashApp('renderer', port);131 const crash = await waitForCrash();132 checkCrash('renderer', crash);133 expect(crash.mainProcessSpecific).to.be.undefined();134 });135 it('when sandboxed renderer crashes', async () => {136 const { port, waitForCrash } = await startServer();137 runCrashApp('sandboxed-renderer', port);138 const crash = await waitForCrash();139 checkCrash('renderer', crash);140 expect(crash.mainProcessSpecific).to.be.undefined();141 });142 // TODO(nornagon): Minidump generation in main/node process on Linux/Arm is143 // broken (//components/crash prints "Failed to generate minidump"). Figure144 // out why.145 ifit(!isLinuxOnArm)('when main process crashes', async () => {146 const { port, waitForCrash } = await startServer();147 runCrashApp('main', port);148 const crash = await waitForCrash();149 checkCrash('browser', crash);150 expect(crash.mainProcessSpecific).to.equal('mps');151 });152 ifit(!isLinuxOnArm)('when a node process crashes', async () => {153 const { port, waitForCrash } = await startServer();154 runCrashApp('node', port);155 const crash = await waitForCrash();156 checkCrash('node', crash);157 expect(crash.mainProcessSpecific).to.be.undefined();158 expect(crash.rendererSpecific).to.be.undefined();159 });160 describe('with guid', () => {161 for (const processType of ['main', 'renderer', 'sandboxed-renderer']) {162 it(`when ${processType} crashes`, async () => {163 const { port, waitForCrash } = await startServer();164 runCrashApp(processType, port);165 const crash = await waitForCrash();166 expect(crash.guid).to.be.a('string');167 });168 }169 it('is a consistent id', async () => {170 let crash1Guid;171 let crash2Guid;172 {173 const { port, waitForCrash } = await startServer();174 runCrashApp('main', port);175 const crash = await waitForCrash();176 crash1Guid = crash.guid;177 }178 {179 const { port, waitForCrash } = await startServer();180 runCrashApp('main', port);181 const crash = await waitForCrash();182 crash2Guid = crash.guid;183 }184 expect(crash2Guid).to.equal(crash1Guid);185 });186 });187 describe('with extra parameters', () => {188 it('when renderer crashes', async () => {189 const { port, waitForCrash } = await startServer();190 runCrashApp('renderer', port, ['--set-extra-parameters-in-renderer']);191 const crash = await waitForCrash();192 checkCrash('renderer', crash);193 expect(crash.mainProcessSpecific).to.be.undefined();194 expect(crash.rendererSpecific).to.equal('rs');195 expect(crash.addedThenRemoved).to.be.undefined();196 });197 it('when sandboxed renderer crashes', async () => {198 const { port, waitForCrash } = await startServer();199 runCrashApp('sandboxed-renderer', port, ['--set-extra-parameters-in-renderer']);200 const crash = await waitForCrash();201 checkCrash('renderer', crash);202 expect(crash.mainProcessSpecific).to.be.undefined();203 expect(crash.rendererSpecific).to.equal('rs');204 expect(crash.addedThenRemoved).to.be.undefined();205 });206 it('contains v8 crash keys when a v8 crash occurs', async () => {207 const { remotely } = await startRemoteControlApp();208 const { port, waitForCrash } = await startServer();209 await remotely((port: number) => {210 require('electron').crashReporter.start({211 submitURL: `http://127.0.0.1:${port}`,212 compress: false,213 ignoreSystemCrashHandler: true214 });215 }, [port]);216 remotely(() => {217 const { BrowserWindow } = require('electron');218 const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });219 bw.loadURL('about:blank');220 bw.webContents.executeJavaScript('process._linkedBinding(\'electron_common_v8_util\').triggerFatalErrorForTesting()');221 });222 const crash = await waitForCrash();223 expect(crash.prod).to.equal('Electron');224 expect(crash._productName).to.equal('electron-test-remote-control');225 expect(crash.process_type).to.equal('renderer');226 expect(crash['electron.v8-fatal.location']).to.equal('v8::Context::New()');227 expect(crash['electron.v8-fatal.message']).to.equal('Circular extension dependency');228 });229 });230 });231 ifdescribe(!isLinuxOnArm)('extra parameter limits', () => {232 function stitchLongCrashParam (crash: any, paramKey: string) {233 if (crash[paramKey]) return crash[paramKey];234 let chunk = 1;235 let stitched = '';236 while (crash[`${paramKey}__${chunk}`]) {237 stitched += crash[`${paramKey}__${chunk}`];238 chunk++;239 }240 return stitched;241 }242 it('should truncate extra values longer than 5 * 4096 characters', async () => {243 const { port, waitForCrash } = await startServer();244 const { remotely } = await startRemoteControlApp();245 remotely((port: number) => {246 require('electron').crashReporter.start({247 submitURL: `http://127.0.0.1:${port}`,248 compress: false,249 ignoreSystemCrashHandler: true,250 extra: { longParam: 'a'.repeat(100000) }251 });252 setTimeout(() => process.crash());253 }, port);254 const crash = await waitForCrash();255 expect(stitchLongCrashParam(crash, 'longParam')).to.have.lengthOf(160 * 127 + (process.platform === 'linux' ? 159 : 0), 'crash should have truncated longParam');256 });257 it('should omit extra keys with names longer than the maximum', async () => {258 const kKeyLengthMax = 39;259 const { port, waitForCrash } = await startServer();260 const { remotely } = await startRemoteControlApp();261 remotely((port: number, kKeyLengthMax: number) => {262 require('electron').crashReporter.start({263 submitURL: `http://127.0.0.1:${port}`,264 compress: false,265 ignoreSystemCrashHandler: true,266 extra: {267 ['a'.repeat(kKeyLengthMax + 10)]: 'value',268 ['b'.repeat(kKeyLengthMax)]: 'value',269 'not-long': 'not-long-value'270 }271 });272 require('electron').crashReporter.addExtraParameter('c'.repeat(kKeyLengthMax + 10), 'value');273 setTimeout(() => process.crash());274 }, port, kKeyLengthMax);275 const crash = await waitForCrash();276 expect(crash).not.to.have.property('a'.repeat(kKeyLengthMax + 10));277 expect(crash).not.to.have.property('a'.repeat(kKeyLengthMax));278 expect(crash).to.have.property('b'.repeat(kKeyLengthMax), 'value');279 expect(crash).to.have.property('not-long', 'not-long-value');280 expect(crash).not.to.have.property('c'.repeat(kKeyLengthMax + 10));281 expect(crash).not.to.have.property('c'.repeat(kKeyLengthMax));282 });283 });284 describe('globalExtra', () => {285 ifit(!isLinuxOnArm)('should be sent with main process dumps', async () => {286 const { port, waitForCrash } = await startServer();287 runCrashApp('main', port, ['--add-global-param=globalParam:globalValue']);288 const crash = await waitForCrash();289 expect(crash.globalParam).to.equal('globalValue');290 });291 it('should be sent with renderer process dumps', async () => {292 const { port, waitForCrash } = await startServer();293 runCrashApp('renderer', port, ['--add-global-param=globalParam:globalValue']);294 const crash = await waitForCrash();295 expect(crash.globalParam).to.equal('globalValue');296 });297 it('should be sent with sandboxed renderer process dumps', async () => {298 const { port, waitForCrash } = await startServer();299 runCrashApp('sandboxed-renderer', port, ['--add-global-param=globalParam:globalValue']);300 const crash = await waitForCrash();301 expect(crash.globalParam).to.equal('globalValue');302 });303 ifit(!isLinuxOnArm)('should not be overridden by extra in main process', async () => {304 const { port, waitForCrash } = await startServer();305 runCrashApp('main', port, ['--add-global-param=mainProcessSpecific:global']);306 const crash = await waitForCrash();307 expect(crash.mainProcessSpecific).to.equal('global');308 });309 ifit(!isLinuxOnArm)('should not be overridden by extra in renderer process', async () => {310 const { port, waitForCrash } = await startServer();311 runCrashApp('main', port, ['--add-global-param=rendererSpecific:global']);312 const crash = await waitForCrash();313 expect(crash.rendererSpecific).to.equal('global');314 });315 });316 // TODO(nornagon): also test crashing main / sandboxed renderers.317 ifit(!isWindowsOnArm)('should not send a minidump when uploadToServer is false', async () => {318 const { port, waitForCrash, getCrashes } = await startServer();319 waitForCrash().then(() => expect.fail('expected not to receive a dump'));320 await runCrashApp('renderer', port, ['--no-upload']);321 // wait a sec in case the crash reporter is about to upload a crash322 await delay(1000);323 expect(getCrashes()).to.have.length(0);324 });325 describe('getUploadedReports', () => {326 it('returns an array of reports', async () => {327 const { remotely } = await startRemoteControlApp();328 await remotely(() => {329 require('electron').crashReporter.start({ submitURL: 'http://127.0.0.1' });330 });331 const reports = await remotely(() => require('electron').crashReporter.getUploadedReports());332 expect(reports).to.be.an('array');333 });334 });335 // TODO(nornagon): re-enable on woa336 ifdescribe(!isWindowsOnArm)('getLastCrashReport', () => {337 it('returns the last uploaded report', async () => {338 const { remotely } = await startRemoteControlApp();339 const { port, waitForCrash } = await startServer();340 // 0. clear the crash reports directory.341 const dir = await remotely(() => require('electron').app.getPath('crashDumps'));342 try {343 fs.rmdirSync(dir, { recursive: true });344 fs.mkdirSync(dir);345 } catch (e) { /* ignore */ }346 // 1. start the crash reporter.347 await remotely((port: number) => {348 require('electron').crashReporter.start({349 submitURL: `http://127.0.0.1:${port}`,350 compress: false,351 ignoreSystemCrashHandler: true352 });353 }, [port]);354 // 2. generate a crash in the renderer.355 remotely(() => {356 const { BrowserWindow } = require('electron');357 const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });358 bw.loadURL('about:blank');359 bw.webContents.executeJavaScript('process.crash()');360 });361 await waitForCrash();362 // 3. get the crash from getLastCrashReport.363 const firstReport = await repeatedly(364 () => remotely(() => require('electron').crashReporter.getLastCrashReport())365 );366 expect(firstReport).to.not.be.null();367 expect(firstReport.date).to.be.an.instanceOf(Date);368 expect((+new Date()) - (+firstReport.date)).to.be.lessThan(30000);369 });370 });371 describe('getParameters', () => {372 it('returns all of the current parameters', async () => {373 const { remotely } = await startRemoteControlApp();374 await remotely(() => {375 require('electron').crashReporter.start({...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci, Cu} = require("chrome");2var DevToolsUtils = require("devtools/toolkit/DevToolsUtils");3var rootActor = null;4var client = null;5var chromeActors = null;6var chromeActor = null;7var appActor = null;8var appActors = null;9var appActor = null;10var appActorFront = null;11var crashType = null;12var crashAddress = null;13var crashThread = null;14var crashExtra = null;15var crashMinidump = null;16var crashId = null;17var crashThreadId = null;18var crashThreadName = null;19var crashThreadRegister = null;20var crashThreadFrame = null;21var crashThreadFrameLine = null;22var crashThreadFrameColumn = null;23var crashThreadFrameSource = null;24var crashThreadFrameFunctionName = null;25var crashThreadFrameDisplayURL = null;26var crashThreadFrameAsyncCause = null;27var crashThreadFrameAsyncParent = null;28var crashThreadFrameAsyncParentLine = null;29var crashThreadFrameAsyncParentColumn = null;30var crashThreadFrameAsyncParentSource = null;31var crashThreadFrameAsyncParentFunctionName = null;32var crashThreadFrameAsyncParentDisplayURL = null;33var crashThreadFrameAsyncParentAsyncCause = null;34var crashThreadFrameAsyncCause = null;35var crashThreadFrameAsyncParent = null;36var crashThreadFrameAsyncParentLine = null;37var crashThreadFrameAsyncParentColumn = null;38var crashThreadFrameAsyncParentSource = null;39var crashThreadFrameAsyncParentFunctionName = null;40var crashThreadFrameAsyncParentDisplayURL = null;41var crashThreadFrameAsyncParentAsyncCause = null;42var crashThreadFrameAsyncCause = null;43var crashThreadFrameAsyncParent = null;44var crashThreadFrameAsyncParentLine = null;45var crashThreadFrameAsyncParentColumn = null;46var crashThreadFrameAsyncParentSource = null;47var crashThreadFrameAsyncParentFunctionName = null;48var crashThreadFrameAsyncParentDisplayURL = null;49var crashThreadFrameAsyncParentAsyncCause = null;

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci, Cu} = require("chrome");2var client = new DebuggerClient(DebuggerServer.connectPipe());3client.connect(function() {4 client.listTabs(function(response) {5 var root = client.mainRoot;6 root.waitForCrash(function() {7 console.log("crash detected");8 });9 });10});11var {Cc, Ci, Cu} = require("chrome");12var client = new DebuggerClient(DebuggerServer.connectPipe());13client.connect(function() {14 client.listTabs(function(response) {15 var root = client.mainRoot;16 root.waitForCrash(function() {17 console.log("browser crashed");18 });19 });20});21var {Cc, Ci, Cu} = require("chrome");22var client = new DebuggerClient(DebuggerServer.connectPipe());23client.connect(function() {24 client.listTabs(function(response) {25 var root = client.mainRoot;26 root.waitForCrash(function() {27 console.log("content process crashed");28 }, { childID: 1 });29 });30});31var {

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci, Cu} = require("chrome");2var {require} = devtools;3var {DebuggerServer} = require("devtools/server/main");4var {DebuggerClient} = require("devtools/toolkit/client/main");5var client = new DebuggerClient(DebuggerServer.connectPipe());6client.connect().then(function () {7 return client.listTabs();8}).then(function (response) {9 return client.attachTab(response.selected);10}).then(function (response) {11 return client.mainRoot;12}).then(function (root) {13 return root.waitForCrash();14}).then(function (response) {15 console.log("Browser has crashed");16 client.close();17});

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci, Cu} = require("chrome");2var devtools = require("devtools");3var {DebuggerServer} = devtools["require"]("devtools/server/main");4var {DebuggerClient} = devtools["require"]("devtools/toolkit/client/main");5var client = new DebuggerClient(DebuggerServer.connectPipe());6client.connect().then(function () {7 client.listTabs(function (response) {8 var root = client.mainRoot;9 root.waitForCrash().then(function () {10 console.log("The application has crashed");11 });12 });13});14var {Cc, Ci, Cu} = require("chrome");15var devtools = require("devtools");16var {DebuggerServer} = devtools["require"]("devtools/server/main");17var {DebuggerClient} = devtools["require"]("devtools/toolkit/client/main");18var client = new DebuggerClient(DebuggerServer.connectPipe());19client.connect().then(function () {20 client.listTabs(function (response) {21 var root = client.mainRoot;22 root.waitForCrash().then(function () {23 console.log("The application has crashed");24 });25 });26});27var {Cc, Ci, Cu} = require("chrome");28var devtools = require("devtools");29var {DebuggerServer} = devtools["require"]("devtools/server/main");30var {DebuggerClient} = devtools["require"]("devtools/toolkit/client/main");31var client = new DebuggerClient(DebuggerServer.connectPipe());32client.connect().then(function () {33 client.listTabs(function (response) {34 var root = client.mainRoot;

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci, Cu} = require("chrome");2var system = require("sdk/system");3var {setTimeout} = require("sdk/timers");4var {require} = devtools;5var {TargetFactory} = require("devtools/framework/target");6var {Toolbox} = require("devtools/framework/toolbox");7var target, toolbox, client, root, threadClient;8function init() {9 DebuggerServer.init();10 DebuggerServer.addBrowserActors();11 DebuggerServer.allowChromeProcess = true;12 let transport = DebuggerServer.connectPipe();13 client = new DebuggerClient(transport);14 client.connect().then(() => {15 return client.listTabs();16 }).then((response) => {17 let targetTab = response.tabs[0];18 target = TargetFactory.forTab(targetTab);19 return gDevTools.showToolbox(target, "jsdebugger");20 }).then((aToolbox) => {21 toolbox = aToolbox;22 root = client.mainRoot;23 threadClient = root.activeTab;24 threadClient.waitForCrash().then(() => {25 console.log("Crash detected");26 });27 Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).invalidateCachesOnRestart();28 Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);29 });30}31init();32var {Cc, Ci, Cu} = require("chrome");33var system = require("sdk/system");34var {setTimeout} = require("sdk/timers");

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci} = require("chrome");2var {DebuggerServer} = require("devtools/server/main");3var {DebuggerClient} = require("devtools/toolkit/client/main");4var {gDevTools} = devtoolsRequire("devtools/client/framework/devtools");5DebuggerServer.init();6DebuggerServer.addBrowserActors();7DebuggerServer.allowChromeProcess = true;8DebuggerServer.chromeWindow = window;9DebuggerServer.openListener(0);10var client = new DebuggerClient(DebuggerServer.connectPipe());11client.connect(function() {12 client.listTabs(function(aResponse) {13 client.attachTab(aResponse.tabs[0].actor, function(aResponse, aTabClient) {14 aTabClient.attachThread(function(aResponse, aThreadClient) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var {Cc, Ci, Cu, Cr} = require("chrome");2var rootActor = Cc["@mozilla.org/remote/rootActor;1"].getService(Ci.nsIRootActor);3rootActor.waitForCrash(function() {4 console.log("Crash occurred");5});6var {Cc, Ci, Cu, Cr} = require("chrome");7var rootActor = Cc["@mozilla.org/remote/rootActor;1"].getService(Ci.nsIRootActor);8rootActor.waitForCrash(function() {9 console.log("Crash occurred");10});11var {Cc, Ci, Cu, Cr} = require("chrome");12var rootActor = Cc["@mozilla.org/remote/rootActor;1"].getService(Ci.nsIRootActor);13rootActor.waitForCrash(function() {14 console.log("Crash occurred");15});16var {Cc, Ci, Cu, Cr} = require("chrome");17var rootActor = Cc["@mozilla.org/remote/rootActor;1"].getService(Ci.nsIRootActor);18rootActor.waitForCrash(function() {19 console.log("Crash occurred");20});21var {Cc, Ci, Cu, Cr} = require("chrome");22var rootActor = Cc["@mozilla.org/remote/rootActor;1"].getService(Ci.nsIRootActor);23rootActor.waitForCrash(function() {24 console.log("Crash occurred");25});26var {Cc, Ci, Cu, Cr} = require("chrome");27var rootActor = Cc["@mozilla.org/remote/rootActor;1"].getService(Ci.nsIRootActor);28rootActor.waitForCrash(function() {29 console.log("Crash occurred");30});31var {Cc, Ci, Cu, Cr} =

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('ui/common/root');2root.waitForCrash(function(){3 alert('crash');4});5exports.waitForCrash = function(callback){6 callback();7}8exports.waitForCrash = function(callback){9 callback();10}11exports.waitForCrash = function(callback){12 callback();13}14exports.waitForCrash = function(callback){15 callback();16}17exports.waitForCrash = function(callback){18 callback();19}20exports.waitForCrash = function(callback){21 callback();22}23exports.waitForCrash = function(callback){24 callback();25}26exports.waitForCrash = function(callback){27 callback();28}29exports.waitForCrash = function(callback){30 callback();31}32exports.waitForCrash = function(callback){33 callback();34}35I have to wait for crash to happen, and then call the callback. I have tried using `Ti.App.addEventListener('uncaughtException', callback);` but it doesn't work. I am not sure if I am doing it right. 36var root = require('ui/common/root');37root.waitForCrash(function(){38 alert('crash');39});40exports.waitForCrash = function(callback){41 var timer = setInterval(function(){42 if(Ti.App.crash){43 clearInterval(timer);44 callback();45 }46 },

Full Screen

Using AI Code Generation

copy

Full Screen

1function waitForCrash() {2 var root = this;3 var crash = root.waitForCrash();4 if (crash) {5 root.log("Crash detected: " + crash);6 }7 else {8 root.log("No crash detected.");9 }10}11function waitForCrash() {12 var root = this;13 var crash = root.waitForCrash(1000);14 if (crash) {15 root.log("Crash detected: " + crash);16 }17 else {18 root.log("No crash detected.");19 }20}21function waitForCrash() {22 var root = this;23 var crash = root.waitForCrash(1000, "test");24 if (crash) {25 root.log("Crash detected: " + crash);26 }27 else {28 root.log("No crash detected.");29 }30}31function waitForCrash() {32 var root = this;33 var crash = root.waitForCrash(1000, "test", "test");34 if (crash) {35 root.log("Crash detected: " + crash);36 }37 else {38 root.log("No crash detected.");39 }40}41function waitForCrash() {42 var root = this;43 var crash = root.waitForCrash(1000, "test", "test", true);44 if (crash) {45 root.log("Crash detected: " + crash);46 }47 else {48 root.log("No crash detected.");49 }50}51function waitForCrash() {52 var root = this;53 var crash = root.waitForCrash(1000, "test", "test", true, true);54 if (crash) {55 root.log("Crash detected: " + crash);56 }57 else {58 root.log("No crash detected.");59 }60}61function waitForCrash() {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run root 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