OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <link rel='manifest' href='foo.json'> |
| 5 </head> |
| 6 <body> |
| 7 <script src="../resources/testharness.js"></script> |
| 8 <script src="../resources/testharnessreport.js"></script> |
| 9 <script> |
| 10 var links = document.getElementsByTagName('link'); |
| 11 |
| 12 test(function() { |
| 13 assert_equals(links[0], window.internals.linkManifest(document)); |
| 14 }, "Test that the parser correctly find the manifest"); |
| 15 |
| 16 test(function() { |
| 17 links[0].href = 'foobar.json'; |
| 18 assert_equals(links[0].href, window.internals.linkManifest(document).href); |
| 19 }, "Test that changing the href will change the known URL"); |
| 20 |
| 21 test(function() { |
| 22 links[0].href = 'htp:/blah'; |
| 23 assert_equals(links[0], window.internals.linkManifest(document)); |
| 24 }, "Test that invalid URL are accepted"); |
| 25 |
| 26 test(function() { |
| 27 links[0].href = ''; |
| 28 assert_equals(links[0], window.internals.linkManifest(document)); |
| 29 }, "Test that empty URL are accepted"); |
| 30 |
| 31 test(function() { |
| 32 links[0].href = 'http://example.com/manifest.json'; |
| 33 assert_equals(links[0], window.internals.linkManifest(document)); |
| 34 }, "Test that cross-origin URL are accepted"); |
| 35 |
| 36 test(function() { |
| 37 links[0].rel = "foo bar manifest"; |
| 38 links[0].href = 'http://example.com/manifest.json'; |
| 39 assert_equals(links[0], window.internals.linkManifest(document)); |
| 40 }, "Test that having multiple tokens in @rel will keep thi link as a manifest"
); |
| 41 |
| 42 test(function() { |
| 43 var link = document.createElement('link'); |
| 44 link.rel = 'manifest'; |
| 45 link.href = 'foobar.json'; |
| 46 document.head.appendChild(link); |
| 47 assert_equals(links[0], window.internals.linkManifest(document)); |
| 48 |
| 49 link = document.createElement('link'); |
| 50 link.rel = 'manifest'; |
| 51 link.href = 'manifest.json'; |
| 52 document.head.insertBefore(link, links[0]); |
| 53 assert_equals(links[0], window.internals.linkManifest(document)); |
| 54 }, "Test that the first manifest is always being used"); |
| 55 |
| 56 test(function() { |
| 57 // Remove all current links. |
| 58 while (document.head.firstChild) |
| 59 document.head.removeChild(document.head.firstChild); |
| 60 |
| 61 // Add link to the body. |
| 62 var link = document.createElement('link'); |
| 63 link.rel = 'manifest'; |
| 64 link.href = 'manifest.json'; |
| 65 document.body.appendChild(link); |
| 66 |
| 67 assert_not_equals(links[0], window.internals.linkManifest(document)); |
| 68 }, "Test that links outside of the head are ignored"); |
| 69 |
| 70 test(function() { |
| 71 // Add a clean <link rel='manifest'>. |
| 72 var link = document.createElement('link'); |
| 73 link.rel = 'manifest'; |
| 74 link.href = 'foobar.json'; |
| 75 link.type = 'application/manifest+json'; |
| 76 document.head.appendChild(link); |
| 77 |
| 78 links[0].crossOrigin = 'use-credentials'; |
| 79 assert_equals(links[0], window.internals.linkManifest(document)); |
| 80 |
| 81 links[0].setAttribute('hreflang', 'klingon'); |
| 82 assert_equals(links[0], window.internals.linkManifest(document)); |
| 83 |
| 84 links[0].type = 'image/gif'; |
| 85 assert_equals(links[0], window.internals.linkManifest(document)); |
| 86 |
| 87 links[0].setAttribute('sizes', '16x16'); |
| 88 assert_equals(links[0], window.internals.linkManifest(document)); |
| 89 }, "Test that attributes on the element do not affect which one is used."); |
| 90 |
| 91 </script> |
| 92 </body> |
| 93 </html> |
OLD | NEW |