mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[gardening] Fix recent change to language/stack_trace/* tests in CSP mode
In CSP mode we cannot use `eval()`, so use static interop mechanism to set stack trace limit. It seems `window` is available in Chrome and others have higher limit anyway. Change-Id: Id57dc86936d0568338a8ee4436e69e39be8eb32c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349483 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
52eece2107
commit
226667e764
|
@ -9,17 +9,26 @@ void configureStackFrameLimit() {
|
|||
// are captured in stack traces (e.g. Chrome's limit is 10).
|
||||
// We can configure that here manually, to ensure the tests pass
|
||||
// on all compiler+browser combinations.
|
||||
eval('''
|
||||
var globalState = (typeof window != "undefined") ? window
|
||||
: (typeof global != "undefined") ? global
|
||||
: (typeof self != "undefined") ? self : null;
|
||||
jsWindow?.error.stackTraceLimit = 100;
|
||||
}
|
||||
|
||||
// By default, stack traces cutoff at 10 in Chrome.
|
||||
if (globalState.Error) {
|
||||
globalState.Error.stackTraceLimit = Infinity;
|
||||
}
|
||||
''');
|
||||
@JS('window')
|
||||
external JSWindow? get jsWindow;
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class JSWindow {}
|
||||
|
||||
extension on JSWindow {
|
||||
@JS('Error')
|
||||
external JSError get error;
|
||||
}
|
||||
|
||||
@JS()
|
||||
external void eval(String code);
|
||||
@staticInterop
|
||||
class JSError {}
|
||||
|
||||
extension on JSError {
|
||||
@JS('stackTraceLimit')
|
||||
external void set stackTraceLimit(int value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue