OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/testharness.js"></script> |
| 5 <script src="../../../resources/testharnessreport.js"></script> |
| 6 <script src="../../../http/tests/htmlimports/resources/import-custom-element-hel
per.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <script> |
| 10 var Hello = registerTestingCustomElement('x-hello'); |
| 11 |
| 12 var t1 = async_test('Instantiate custom elements in async imports.'); |
| 13 var t2 = async_test('Resolve custom elements in async imports later.'); |
| 14 var numberOfLinks = 6 + 4; // + 4 for grandchildren |
| 15 var expectedHelloList = ['hello-1', 'hello-2', 'hello-3', 'hello-4', 'hello-5',
'hello-6', 'hello-7', 'hello-8', 'hello-p34-1', 'hello-p34-2', 'hello-p56-1', 'h
ello-p56-2']; |
| 16 var expectedByeList = ['bye-1', 'bye-2', 'bye-3', 'bye-4', 'bye-5', 'bye-6', 'by
e-7', 'bye-8', 'bye-p34-1', 'bye-p34-2', 'bye-p56-1', 'bye-p56-2']; |
| 17 |
| 18 var latch = new ImportTestLatch(function() { |
| 19 |
| 20 t1.step(function() { |
| 21 assert_equals('hello-1', Hello.ids[0]); |
| 22 assert_array_equals(expectedHelloList, Hello.ids.slice(0).sort()); |
| 23 |
| 24 assert_true(Hello.ids.indexOf('hello-p34-1') < Hello.ids.indexOf('hello-
3'), 'Order check heello-3'); |
| 25 assert_true(Hello.ids.indexOf('hello-3') < Hello.ids.indexOf('hello-p34-
2'), 'Order check hello-p34-2'); |
| 26 assert_true(Hello.ids.indexOf('hello-3') < Hello.ids.indexOf('hello-7'),
'Order check hello-7'); |
| 27 |
| 28 // Even though parent-2 is loaded in async, its content should follow th
e order. |
| 29 assert_true(Hello.ids.indexOf('hello-p56-1') < Hello.ids.indexOf('hello-
5'), 'Order check hello-5'); |
| 30 assert_true(Hello.ids.indexOf('hello-5') < Hello.ids.indexOf('hello-p56-
2'), 'Order check hellop56-2'); |
| 31 |
| 32 t1.done(); |
| 33 }); |
| 34 |
| 35 t2.step(function() { |
| 36 var Bye = registerTestingCustomElement('x-bye'); |
| 37 |
| 38 assert_equals('bye-1', Bye.ids[0]); |
| 39 assert_array_equals(expectedByeList, Bye.ids.slice(0).sort()); |
| 40 assert_true(Bye.ids.indexOf('bye-p34-1') < Bye.ids.indexOf('bye-3')); |
| 41 assert_true(Bye.ids.indexOf('bye-3') < Bye.ids.indexOf('bye-p34-2')); |
| 42 assert_true(Bye.ids.indexOf('bye-3') < Bye.ids.indexOf('bye-7')); |
| 43 assert_true(Bye.ids.indexOf('bye-p56-1') < Bye.ids.indexOf('bye-5')); |
| 44 assert_true(Bye.ids.indexOf('bye-5') < Bye.ids.indexOf('bye-p56-2')); |
| 45 |
| 46 t2.done(); |
| 47 }); |
| 48 }, numberOfLinks); |
| 49 </script> |
| 50 <link rel="import" href="resources/custom-element-hello-1.html" onload="latch.lo
aded()"> |
| 51 <link rel="import" href="resources/custom-element-hello-2.html" async onload="la
tch.loaded()"> |
| 52 <link rel="import" href="resources/custom-element-hello-parent-34.html" onload="
latch.loaded()"> |
| 53 <link rel="import" href="resources/custom-element-hello-parent-56.html" async on
load="latch.loaded()"> |
| 54 <link rel="import" href="resources/custom-element-hello-7.html" onload="latch.lo
aded()"> |
| 55 <script> |
| 56 (function() { |
| 57 var link = document.createElement('link'); |
| 58 link.href = 'resources/custom-element-hello-8.html'; |
| 59 link.rel = 'import'; |
| 60 link.onload = latch.loaded.bind(latch); |
| 61 document.head.appendChild(link); |
| 62 })(); |
| 63 </script> |
| 64 </body> |
| 65 </html> |
OLD | NEW |