Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: LayoutTests/manifest/link-manifest-url.html

Issue 270283007: Implement the logic to find the correct <link> for Manifest in Document. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@link_manifest
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/Document.h » ('j') | Source/core/dom/Document.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5a038ec2998769b976fff6517265ab99b162992d
--- /dev/null
+++ b/LayoutTests/manifest/link-manifest-url.html
@@ -0,0 +1,93 @@
+<!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], window.internals.linkManifest(document));
+ }, "Test that the parser correctly find the manifest");
+
+ test(function() {
+ links[0].href = 'foobar.json';
+ assert_equals(links[0].href, window.internals.linkManifest(document).href);
+ }, "Test that changing the href will change the known URL");
+
+ test(function() {
+ links[0].href = 'htp:/blah';
+ assert_equals(links[0], window.internals.linkManifest(document));
+ }, "Test that invalid URL are accepted");
+
+ test(function() {
+ links[0].href = '';
+ assert_equals(links[0], window.internals.linkManifest(document));
+ }, "Test that empty URL are accepted");
+
+ test(function() {
+ links[0].href = 'http://example.com/manifest.json';
+ assert_equals(links[0], window.internals.linkManifest(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], window.internals.linkManifest(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], window.internals.linkManifest(document));
+
+ link = document.createElement('link');
+ link.rel = 'manifest';
+ link.href = 'manifest.json';
+ document.head.insertBefore(link, links[0]);
+ assert_equals(links[0], window.internals.linkManifest(document));
+ }, "Test that the first manifest is always 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], window.internals.linkManifest(document));
+ }, "Test that links outside of the head are ignored");
+
+ test(function() {
+ // Add a clean <link rel='manifest'>.
+ var link = document.createElement('link');
+ link.rel = 'manifest';
+ link.href = 'foobar.json';
+ link.type = 'application/manifest+json';
+ document.head.appendChild(link);
+
+ links[0].crossOrigin = 'use-credentials';
+ assert_equals(links[0], window.internals.linkManifest(document));
+
+ links[0].setAttribute('hreflang', 'klingon');
+ assert_equals(links[0], window.internals.linkManifest(document));
+
+ links[0].type = 'image/gif';
+ assert_equals(links[0], window.internals.linkManifest(document));
+
+ links[0].setAttribute('sizes', '16x16');
+ assert_equals(links[0], window.internals.linkManifest(document));
+ }, "Test that attributes on the element do not affect which one is used.");
+
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | Source/core/dom/Document.h » ('j') | Source/core/dom/Document.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698