Chromium Code Reviews| Index: LayoutTests/fast/html/imports/import-custom-element-async-resolve.html |
| diff --git a/LayoutTests/fast/html/imports/import-custom-element-async-resolve.html b/LayoutTests/fast/html/imports/import-custom-element-async-resolve.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bb7b28678623eca38dccea111f7c458cb4fc16ab |
| --- /dev/null |
| +++ b/LayoutTests/fast/html/imports/import-custom-element-async-resolve.html |
| @@ -0,0 +1,62 @@ |
| +<!DOCTYPE html> |
|
dominicc (has gone to gerrit)
2014/04/24 07:28:33
I think you want way more tests at this point. For
|
| +<html> |
| +<head> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +</head> |
| +<body> |
| +<script> |
| + |
| +Hello = function() {}; |
| +Hello.ids = []; |
| +Hello.prototype = Object.create(HTMLElement.prototype); |
| +Hello.prototype.createdCallback = function() { Hello.ids.push(this.id); } |
| +document.registerElement('x-hello', Hello); |
|
dominicc (has gone to gerrit)
2014/04/24 07:28:33
Why is Hello in PascalCase? It's not the real cons
|
| + |
| +var numLoadedImports = 0; |
| + |
| +function importLoaded() |
| +{ |
| + numLoadedImports++; |
| + if (numLoadedImports == 3) |
| + test(); |
| +} |
| + |
| +var t1 = async_test('Instantiate custom elements in Async imports'); |
|
dominicc (has gone to gerrit)
2014/04/24 07:28:33
Async -> async
next line too
|
| +var t2 = async_test('Resolve custom elements in Async imports later'); |
| + |
| +function test() |
| +{ |
|
dominicc (has gone to gerrit)
2014/04/24 07:28:33
Open brace goes on the previous line. Below too.
|
| + t1.step(function() |
| + { |
| + assert_array_equals(['hello-1', 'hello-2', 'hello-3'], Hello.ids.sort()); |
|
dominicc (has gone to gerrit)
2014/04/24 07:28:33
You must be able to write a tighter assertion than
|
| + t1.done(); |
| + }); |
| + |
| + t2.step(function() |
| + { |
| + Bye = function() {}; |
|
dominicc (has gone to gerrit)
2014/04/24 07:28:33
Since this is essentially the same as Hello, you c
|
| + Bye.ids = []; |
| + Bye.prototype = Object.create(HTMLElement.prototype); |
| + Bye.prototype.createdCallback = function() { Bye.ids.push(this.id); } |
| + document.registerElement('x-bye', Bye); |
| + |
| + assert_array_equals(['bye-1', 'bye-2', 'bye-3'], Bye.ids.sort()); |
| + t2.done(); |
| + }); |
| +} |
| +</script> |
| +<link rel="import" href="resources/custom-element-hello-1.html" onload="importLoaded()"> |
| +<link rel="import" href="resources/custom-element-hello-2.html" async onload="importLoaded()"> |
| +<script> |
| +(function() |
| +{ |
| + var link = document.createElement('link'); |
| + link.href = ('resources/custom-element-hello-3.html'); |
| + link.rel = 'import'; |
| + link.onload = importLoaded; |
| + document.head.appendChild(link); |
| +})(); |
| +</script> |
| +</body> |
| +</html> |