Skip to content

Commit

Permalink
check args
Browse files Browse the repository at this point in the history
  • Loading branch information
Eriko Kurimoto committed Mar 19, 2020
1 parent f8e39d7 commit 05cdfbc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
22 changes: 16 additions & 6 deletions workers/modules/shared-worker-parse-error-failure.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,31 @@
);
});

const checkArguments = (args) => {
assert_equals(args.a.constructor, Event);
assert_true('message' in args.a, 'Event.message');
assert_equals(typeof args.a.message, 'string', 'Event.message');
assert_equals(args.a.filename, location.href + '/resources/syntax-error.js');
assert_equals(args.a.lineno, 1, 'Event.lineno');
assert_equals(args.b, undefined, 'unexpected second argument to onerror');
assert_equals(args.c, undefined, 'unexpected third argument to onerror');
};

promise_test(async () => {
const scriptURL = 'resources/syntax-error.js';
const worker = new SharedWorker(scriptURL, { type: 'module' });
const type = await new Promise(resolve =>
worker.onerror = error => resolve(error.type));
assert_equals(type, 'error');
const args = await new Promise(resolve =>
worker.onerror = (a, b, c) => resolve({a, b, c}));
checkArguments(args);
}, 'Module shared worker construction for script with syntax error should ' +
'dispatch an event named error.');

promise_test(async () => {
const scriptURL = 'resources/static-import-syntax-error.js';
const worker = new SharedWorker(scriptURL, { type: 'module' });
const type = await new Promise(resolve =>
worker.onerror = error => resolve(error.type));
assert_equals(type, 'error');
const args = await new Promise(resolve =>
worker.onerror = (a, b, c) => resolve({a, b, c}));
checkArguments(args);
}, 'Static import on module shared worker for script with syntax error ' +
'should dispatch an event named error.');

Expand Down
22 changes: 16 additions & 6 deletions workers/shared-worker-parse-error-failure.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@
<script src="/resources/testharnessreport.js"></script>
<script>

const checkArguments = (args) => {
assert_equals(args.a.constructor, Event);
assert_true('message' in args.a, 'Event.message');
assert_equals(typeof args.a.message, 'string', 'Event.message');
assert_equals(args.a.filename, location.href + '/resources/syntax-error.js');
assert_equals(args.a.lineno, 1, 'Event.lineno');
assert_equals(args.b, undefined, 'unexpected second argument to onerror');
assert_equals(args.c, undefined, 'unexpected third argument to onerror');
};

promise_test(async () => {
const scriptURL = 'modules/resources/syntax-error.js';
const worker = new SharedWorker(scriptURL, { type: 'classic' });
const type = await new Promise(resolve =>
worker.onerror = error => resolve(error.type));
assert_equals(type, 'error');
const args = await new Promise(resolve =>
worker.onerror = (a, b, c) => resolve({a, b, c}));
checkArguments(args);
}, 'Classic shared worker construction for script with syntax error should ' +
'dispatch an event named error.');

promise_test(async () => {
const scriptURL = 'modules/resources/static-import-worker.js';
const worker = new SharedWorker(scriptURL, { type: 'classic' });
const type = await new Promise(resolve =>
worker.onerror = error => resolve(error.type));
assert_equals(type, 'error');
const args = await new Promise(resolve =>
worker.onerror = (a, b, c) => resolve({a, b, c}));
checkArguments(args);
}, 'Static import on classic shared worker should dispatch an event named ' +
'error.');

Expand Down

0 comments on commit 05cdfbc

Please sign in to comment.