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

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

Issue 2657823002: Worklet: Straighten layering of worklet script loading (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | third_party/WebKit/Source/core/workers/Worklet.h » ('j') | 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.import(path + 'resources/empty-worklet-script.js').then(f unction(undefined_arg) { 9 return worklet.import(path + 'resources/empty-worklet-script.js').then(f unction(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 }).catch(function(error) { 11 }).catch(function(error) {
12 assert_unreached('unexpected rejection: ' + error); 12 assert_unreached('unexpected rejection: ' + error);
13 }); 13 });
14
15 }, 'Importing a script resolves the given promise.'); 14 }, 'Importing a script resolves the given promise.');
16 15
17 promise_test(function() { 16 promise_test(function() {
17 return Promise.all([
18 worklet.import(path + 'resources/empty-worklet-script.js?1'),
19 worklet.import(path + 'resources/empty-worklet-script.js?2'),
20 worklet.import(path + 'resources/empty-worklet-script.js?3')
21 ]).then(function(undefined_args) {
22 assert_array_equals(undefined_args, [undefined, undefined, undefined ], 'Promise should resolve with no arguments.');
23 }).catch(function(error) {
24 assert_unreached('unexpected rejection: ' + error);
yhirano 2017/01/25 10:49:20 You don't need this catch section.
nhiroki 2017/01/27 04:40:33 Done.
25 });
26 }, 'Importing scripts resolves all the given promises.');
18 27
28 promise_test(function() {
19 return worklet.import(path + 'resources/throwing-worklet-script.js').the n(function(undefined_arg) { 29 return worklet.import(path + 'resources/throwing-worklet-script.js').the n(function(undefined_arg) {
20 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.'); 30 assert_equals(undefined_arg, undefined, 'Promise should resolve with no arguments.');
21 }).catch(function(error) { 31 }).catch(function(error) {
yhirano 2017/01/25 10:49:20 ditto (though unrelated to this CL)
nhiroki 2017/01/27 04:40:33 Done.
22 assert_unreached('unexpected rejection: ' + error); 32 assert_unreached('unexpected rejection: ' + error);
23 }); 33 });
24
25 }, 'Importing a script which throws should still resolve the given promise.' ); 34 }, 'Importing a script which throws should still resolve the given promise.' );
26 35
27 promise_test(function() { 36 promise_test(function() {
28
29 return worklet.import(path + 'non-existant-worklet-script.js').then(func tion() { 37 return worklet.import(path + 'non-existant-worklet-script.js').then(func tion() {
30 assert_unreached('import should fail.'); 38 assert_unreached('import should fail.');
31 }).catch(function(error) { 39 }).catch(function(error) {
32 assert_equals(error.name, 'NetworkError', 'error should be a Network Error.'); 40 assert_equals(error.name, 'NetworkError', 'error should be a Network Error.');
33 }); 41 });
34
35 }, 'Importing a non-existant script rejects the given promise with a Network Error.'); 42 }, 'Importing a non-existant script rejects the given promise with a Network Error.');
36 43
37 promise_test(function() { 44 promise_test(function() {
38
39 return worklet.import('http://invalid:123$').then(function() { 45 return worklet.import('http://invalid:123$').then(function() {
40 assert_unreached('import should fail.'); 46 assert_unreached('import should fail.');
41 }).catch(function(error) { 47 }).catch(function(error) {
42 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr ror.'); 48 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr ror.');
43 }); 49 });
44
45 }, 'Attempting to resolve an invalid URL should reject the given promise wit h a SyntaxError.'); 50 }, 'Attempting to resolve an invalid URL should reject the given promise wit h a SyntaxError.');
46 } 51 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/workers/Worklet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698