OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Fetching import</title> |
| 5 <link rel="help" href="http://w3c.github.io/webcomponents/spec/imports/#fetching
-import"> |
| 6 <script src="../../../../resources/testharness.js"></script> |
| 7 <script src="../../../../resources/testharnessreport.js"></script> |
| 8 <link rel="stylesheet" href="../../../../resources/testharness.css"> |
| 9 |
| 10 <script> |
| 11 var onloadWasCalledOnSuccess = false; |
| 12 var onerrorWasCalledOnSuccess = false; |
| 13 function helloLoadHandler() { onloadWasCalledOnSuccess = true; } |
| 14 function helloErrorHandler() { onerrorWasCalledOnSuccess = true; } |
| 15 |
| 16 var onloadWasCalledOnFail = false; |
| 17 var onerrorWasCalledOnFail = false; |
| 18 function nosuchLoadHandler() { onloadWasCalledOnFail = true; } |
| 19 function nosuchErrorHandler() { onerrorWasCalledOnFail = true; } |
| 20 </script> |
| 21 |
| 22 <link rel="import" href="resources/hello.html" onload="helloLoadHandler()" onerr
or="helloLoadHandler()"> |
| 23 <link rel="import" href="resources/no-such.html" onload="nosuchLoadHandler()" on
error="nosuchErrorHandler()"> |
| 24 |
| 25 <script> |
| 26 test(function() { |
| 27 assert_true(onloadWasCalledOnSuccess); |
| 28 assert_false(onerrorWasCalledOnSuccess); |
| 29 }, 'The loading attempt must be considered successful if IMPORT is not null on t
he algorithm completion, and failed otherwise. (1)'); |
| 30 |
| 31 test(function() { |
| 32 assert_false(onloadWasCalledOnFail); |
| 33 assert_true(onerrorWasCalledOnFail); |
| 34 }, 'The loading attempt must be considered successful if IMPORT is not null on t
he algorithm completion, and failed otherwise. (2)'); |
| 35 |
| 36 t1 = async_test('The loading attempt must be considered successful if IMPORT is
not null on the algorithm completion, and failed otherwise. (3)') |
| 37 t1.step(function() { |
| 38 var importElement = document.createElement('link'); |
| 39 importElement.setAttribute('rel', 'import'); |
| 40 importElement.setAttribute('href', 'resources/dynamic.html'); |
| 41 importElement.addEventListener("error", assert_unreached); |
| 42 importElement.addEventListener("load", function() { |
| 43 t1.done(); |
| 44 }); |
| 45 |
| 46 document.head.appendChild(importElement); |
| 47 }); |
| 48 |
| 49 var onloadWasCalledOnAsync = false; |
| 50 var onerrorWasCalledOnAsync = false; |
| 51 var asyncAttemptDone = function() { assert_unreached(); }; |
| 52 |
| 53 function asyncLoadHandler() { |
| 54 onloadWasCalledOnAsync = true; |
| 55 asyncAttemptDone(); |
| 56 } |
| 57 function asyncErrorHandler() { |
| 58 onerrorWasCalledOnAsync = true; |
| 59 asyncAttemptDone(); |
| 60 } |
| 61 |
| 62 t2 = async_test('Every import that is not marked as async delays the load event
in the Document.'); |
| 63 asyncAttemptDone = function() { |
| 64 t2.step(function() { |
| 65 assert_true(onloadWasCalledOnAsync); |
| 66 assert_false(onerrorWasCalledOnAsync); |
| 67 t2.done(); |
| 68 }); |
| 69 }; |
| 70 |
| 71 </script> |
| 72 <link rel="import" href="resources/async.html" onload="asyncLoadHandler()" onerr
or="asyncErrorHandler()" async> |
| 73 </head> |
| 74 <body> |
| 75 <div id="log"></div> |
| 76 </body> |
| 77 </html> |
OLD | NEW |