fix: stacktraces should not throw errors (#10231)
This commit is contained in:
parent
cf28dae775
commit
557ec24cfc
@ -50,8 +50,9 @@ export function createEvaluationError(
|
|||||||
name = 'Error';
|
name = 'Error';
|
||||||
message = details.text;
|
message = details.text;
|
||||||
} else if (
|
} else if (
|
||||||
details.exception.type !== 'object' ||
|
(details.exception.type !== 'object' ||
|
||||||
details.exception.subtype !== 'error'
|
details.exception.subtype !== 'error') &&
|
||||||
|
!details.exception.objectId
|
||||||
) {
|
) {
|
||||||
return valueFromRemoteObject(details.exception);
|
return valueFromRemoteObject(details.exception);
|
||||||
} else {
|
} else {
|
||||||
@ -110,8 +111,9 @@ export function createClientError(
|
|||||||
name = 'Error';
|
name = 'Error';
|
||||||
message = details.text;
|
message = details.text;
|
||||||
} else if (
|
} else if (
|
||||||
details.exception.type !== 'object' ||
|
(details.exception.type !== 'object' ||
|
||||||
details.exception.subtype !== 'error'
|
details.exception.subtype !== 'error') &&
|
||||||
|
!details.exception.objectId
|
||||||
) {
|
) {
|
||||||
return valueFromRemoteObject(details.exception);
|
return valueFromRemoteObject(details.exception);
|
||||||
} else {
|
} else {
|
||||||
|
@ -587,6 +587,12 @@
|
|||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["FAIL"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[stacktrace.spec] Stack trace *",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["cdp", "firefox"],
|
||||||
|
"expectations": ["FAIL"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[TargetManager.spec] *",
|
"testIdPattern": "[TargetManager.spec] *",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -2220,28 +2226,10 @@
|
|||||||
"expectations": ["SKIP"]
|
"expectations": ["SKIP"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[stacktrace.spec] Stack trace should work",
|
"testIdPattern": "[stacktrace.spec] Stack trace should work for none error objects",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["FAIL"]
|
"expectations": ["PASS"]
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[stacktrace.spec] Stack trace should work with contiguous evaluation",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["cdp", "firefox"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[stacktrace.spec] Stack trace should work with handles",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["cdp", "firefox"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[stacktrace.spec] Stack trace should work with nested function calls",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["cdp", "firefox"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[target.spec] Target Browser.waitForTarget should wait for a target",
|
"testIdPattern": "[target.spec] Target Browser.waitForTarget should wait for a target",
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
setupTestBrowserHooks,
|
setupTestBrowserHooks,
|
||||||
setupTestPageAndContextHooks,
|
setupTestPageAndContextHooks,
|
||||||
} from './mocha-utils.js';
|
} from './mocha-utils.js';
|
||||||
|
import {waitEvent} from './utils.js';
|
||||||
|
|
||||||
const FILENAME = __filename.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
const FILENAME = __filename.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ describe('Stack trace', function () {
|
|||||||
expect(error.stack.split('\n at ').slice(0, 2)).toMatchObject({
|
expect(error.stack.split('\n at ').slice(0, 2)).toMatchObject({
|
||||||
...[
|
...[
|
||||||
'Error: Test',
|
'Error: Test',
|
||||||
'evaluate (evaluate at Context.<anonymous> (<filename>:31:14), <anonymous>:1:18)',
|
'evaluate (evaluate at Context.<anonymous> (<filename>:32:14), <anonymous>:1:18)',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -71,7 +72,7 @@ describe('Stack trace', function () {
|
|||||||
expect(error.stack.split('\n at ').slice(0, 2)).toMatchObject({
|
expect(error.stack.split('\n at ').slice(0, 2)).toMatchObject({
|
||||||
...[
|
...[
|
||||||
'Error: Test',
|
'Error: Test',
|
||||||
'evaluateHandle (evaluateHandle at Context.<anonymous> (<filename>:51:14), <anonymous>:1:18)',
|
'evaluateHandle (evaluateHandle at Context.<anonymous> (<filename>:52:14), <anonymous>:1:18)',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -99,8 +100,8 @@ describe('Stack trace', function () {
|
|||||||
expect(error.stack.split('\n at ').slice(0, 3)).toMatchObject({
|
expect(error.stack.split('\n at ').slice(0, 3)).toMatchObject({
|
||||||
...[
|
...[
|
||||||
'Error: Test',
|
'Error: Test',
|
||||||
'evaluateHandle (evaluateHandle at Context.<anonymous> (<filename>:70:36), <anonymous>:2:22)',
|
'evaluateHandle (evaluateHandle at Context.<anonymous> (<filename>:71:36), <anonymous>:2:22)',
|
||||||
'evaluate (evaluate at Context.<anonymous> (<filename>:76:14), <anonymous>:1:12)',
|
'evaluate (evaluate at Context.<anonymous> (<filename>:77:14), <anonymous>:1:12)',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -135,12 +136,26 @@ describe('Stack trace', function () {
|
|||||||
expect(error.stack.split('\n at ').slice(0, 6)).toMatchObject({
|
expect(error.stack.split('\n at ').slice(0, 6)).toMatchObject({
|
||||||
...[
|
...[
|
||||||
'Error: Test',
|
'Error: Test',
|
||||||
'a (evaluate at Context.<anonymous> (<filename>:97:14), <anonymous>:2:22)',
|
'a (evaluate at Context.<anonymous> (<filename>:98:14), <anonymous>:2:22)',
|
||||||
'b (evaluate at Context.<anonymous> (<filename>:97:14), <anonymous>:5:16)',
|
'b (evaluate at Context.<anonymous> (<filename>:98:14), <anonymous>:5:16)',
|
||||||
'c (evaluate at Context.<anonymous> (<filename>:97:14), <anonymous>:8:16)',
|
'c (evaluate at Context.<anonymous> (<filename>:98:14), <anonymous>:8:16)',
|
||||||
'd (evaluate at Context.<anonymous> (<filename>:97:14), <anonymous>:11:16)',
|
'd (evaluate at Context.<anonymous> (<filename>:98:14), <anonymous>:11:16)',
|
||||||
'evaluate (evaluate at Context.<anonymous> (<filename>:97:14), <anonymous>:13:12)',
|
'evaluate (evaluate at Context.<anonymous> (<filename>:98:14), <anonymous>:13:12)',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work for none error objects', async () => {
|
||||||
|
const {page} = getTestState();
|
||||||
|
|
||||||
|
const [error] = await Promise.all([
|
||||||
|
waitEvent<Error>(page, 'pageerror'),
|
||||||
|
page.evaluate(() => {
|
||||||
|
// This can happen when a 404 with HTML is returned
|
||||||
|
void Promise.reject(new Response());
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(error).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user