Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/worklet/resources/import-tests.js

Issue 2906013002: Worklet: Add layout tests for module import statements on WorkletGlobalScope (Closed)
Patch Set: fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/worklet/resources/import-nested-worklet-script.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Runs a series of tests related to importing scripts on a worklet. 1 // Runs a series of tests related to importing scripts on a worklet.
2 // 2 //
3 // Usage: 3 // Usage:
4 // runImportTests(workletType); 4 // runImportTests(workletType);
5 function runImportTests(worklet, opt_path) { 5 function runImportTests(worklet, opt_path) {
6 const path = opt_path || ''; 6 const path = opt_path || '';
7 7
8 promise_test(function() { 8 promise_test(function() {
9 return worklet.addModule(path + 'resources/empty-worklet-script.js').the n(function(undefined_arg) { 9 return worklet.addModule(path + 'resources/empty-worklet-script.js').the n(function(undefined_arg) {
10 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.'); 10 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.');
11 }); 11 });
12 }, 'Importing a script resolves the given promise.'); 12 }, 'Importing a script resolves the given promise.');
13 13
14 promise_test(function() { 14 promise_test(function() {
15 return Promise.all([ 15 return Promise.all([
16 worklet.addModule(path + 'resources/empty-worklet-script.js?1'), 16 worklet.addModule(path + 'resources/empty-worklet-script.js?1'),
17 worklet.addModule(path + 'resources/empty-worklet-script.js?2'), 17 worklet.addModule(path + 'resources/empty-worklet-script.js?2'),
18 worklet.addModule(path + 'resources/empty-worklet-script.js?3') 18 worklet.addModule(path + 'resources/empty-worklet-script.js?3')
19 ]).then(function(undefined_args) { 19 ]).then(function(undefined_args) {
20 assert_array_equals(undefined_args, [undefined, undefined, undefined ], 'Promise should resolve with no arguments.'); 20 assert_array_equals(undefined_args, [undefined, undefined, undefined ], 'Promise should resolve with no arguments.');
21 }); 21 });
22 }, 'Importing scripts resolves all the given promises.'); 22 }, 'Importing scripts resolves all the given promises.');
23 23
24 promise_test(function() { 24 promise_test(function() {
25 return worklet.addModule(path + 'resources/import-nested-worklet-script. js').then(function(undefined_arg) {
26 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.');
27 });
28 }, 'Importing nested scripts resolves the given promise');
29
30 promise_test(function() {
31 return worklet.addModule(path + 'resources/import-cyclic-worklet-script. js').then(function(undefined_arg) {
32 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.');
33 });
34 }, 'Importing cyclic scripts resolves the given promise');
35
36 promise_test(function() {
25 return worklet.addModule(path + 'resources/throwing-worklet-script.js'). then(function(undefined_arg) { 37 return worklet.addModule(path + 'resources/throwing-worklet-script.js'). then(function(undefined_arg) {
26 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.'); 38 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.');
27 }); 39 });
28 }, 'Importing a script which throws should still resolve the given promise.' ); 40 }, 'Importing a script which throws should still resolve the given promise.' );
29 41
30 promise_test(function() { 42 promise_test(function() {
31 return worklet.addModule(path + 'non-existant-worklet-script.js').then(f unction() { 43 return worklet.addModule(path + 'non-existant-worklet-script.js').then(f unction() {
32 assert_unreached('addModule should fail.'); 44 assert_unreached('addModule should fail.');
33 }).catch(function(error) { 45 }).catch(function(error) {
34 assert_equals(error.name, 'NetworkError', 'error should be a Network Error.'); 46 assert_equals(error.name, 'NetworkError', 'error should be a Network Error.');
35 }); 47 });
36 }, 'Importing a non-existant script rejects the given promise with a Network Error.'); 48 }, 'Importing a non-existant script rejects the given promise with a Network Error.');
37 49
38 promise_test(function() { 50 promise_test(function() {
39 return worklet.addModule('http://invalid:123$').then(function() { 51 return worklet.addModule('http://invalid:123$').then(function() {
40 assert_unreached('addModule should fail.'); 52 assert_unreached('addModule should fail.');
41 }).catch(function(error) { 53 }).catch(function(error) {
42 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr ror.'); 54 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr ror.');
43 }); 55 });
44 }, 'Attempting to resolve an invalid URL should reject the given promise wit h a SyntaxError.'); 56 }, 'Attempting to resolve an invalid URL should reject the given promise wit h a SyntaxError.');
45 } 57 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/worklet/resources/import-nested-worklet-script.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698