Index: LayoutTests/manifest/link-manifest-url.html |
diff --git a/LayoutTests/manifest/link-manifest-url.html b/LayoutTests/manifest/link-manifest-url.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ebfa03f8b24a121376b3123fe272509573dc06f4 |
--- /dev/null |
+++ b/LayoutTests/manifest/link-manifest-url.html |
@@ -0,0 +1,72 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+ <link rel='manifest' href='foo.json'> |
+</head> |
+<body> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script> |
+ var links = document.getElementsByTagName('link'); |
+ |
+ test(function() { |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that the parser correctly find the manifest"); |
+ |
+ test(function() { |
+ links[0].href = 'foobar.json'; |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that changing the href will change the known URL"); |
+ |
+ test(function() { |
+ links[0].href = 'htp:/blah'; |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that invalid URL are accepted"); |
+ |
+ test(function() { |
+ links[0].href = ''; |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that empty URL are accepted"); |
+ |
+ test(function() { |
+ links[0].href = 'http://example.com/manifest.json'; |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that cross-origin URL are accepted"); |
+ |
+ test(function() { |
+ links[0].rel = "foo bar manifest"; |
+ links[0].href = 'http://example.com/manifest.json'; |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that having multiple tokens in @rel will keep thi link as a manifest"); |
+ |
+ test(function() { |
+ var link = document.createElement('link'); |
+ link.rel = 'manifest'; |
+ link.href = 'foobar.json'; |
+ document.head.appendChild(link); |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ |
+ link = document.createElement('link'); |
+ link.rel = 'manifest'; |
+ link.href = 'manifest.json'; |
+ document.head.insertBefore(link, links[0]); |
+ assert_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that the first manifest link is being used"); |
+ |
+ test(function() { |
+ // Remove all current links. |
+ while (document.head.firstChild) |
+ document.head.removeChild(document.head.firstChild); |
+ |
+ // Add link to the body. |
+ var link = document.createElement('link'); |
+ link.rel = 'manifest'; |
+ link.href = 'manifest.json'; |
+ document.body.appendChild(link); |
+ |
+ assert_not_equals(links[0].href, window.internals.manifestURL(document)); |
+ }, "Test that links outside of the head are ignored"); |
+ |
+</script> |
+</body> |
+</html> |