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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/html/infrastructure/urls/terminology-0/document-base-url.html

Issue 2648173006: Import wpt@cf62b859e6b890abc34f8140d185ba91df95c5b6 (Closed)
Patch Set: Rebased Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>HTML Test: document base URL</title>
4 <link rel="author" title="Intel" href="http://www.intel.com/">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <style>
8 iframe { display: none }
9 </style>
10 <body onload="on_load()">
11 <div id="log"></div>
12 <script>
13 function assert_resolve_url(doc, base) {
14 var img = doc.createElement("img");
15 img.src = "foo";
16 var actual = img.src;
17 var expected = base + "/foo";
18 assert_equals(actual, expected, "img src should resolve correctly");
19 }
20
21 var t1 = async_test("The document base URL of a document containing one or m ore base elements with href attributes is the frozen base URL of the first base element in the document that has an href attribute, in tree order.");
22
23 function on_load() {
24 t1.step(function () {
25 var base = document.createElement("base");
26 base.setAttribute("href", "/foo/bar");
27 document.head.appendChild(base);
28 t1.add_cleanup(function () {
29 document.head.removeChild(base);
30 });
31
32 assert_resolve_url(document, location.href.replace(location.pathname, "/ foo"));
33 assert_equals(document.baseURI, base.href, "The document base URL should be URL of the first base element that has an href attribute.");
34 });
35 t1.done();
36 }
37
38 async_test(function() {
39 var iframe = document.createElement("iframe");
40 iframe.onload = this.step_func_done(function () {
41 assert_resolve_url(iframe.contentDocument, location.href.replace(locatio n.pathname, "/common"));
42 assert_equals(iframe.contentDocument.baseURI, iframe.contentDocument.loc ation.href, "The document base URL should be the document's address.");
43 });
44 iframe.setAttribute("src", "/common/blank.html");
45 document.body.appendChild(iframe);
46 }, "The fallback base URL of a document containing no base element is the do cument's address.");
47
48 async_test(function () {
49 var iframe = document.createElement("iframe");
50 iframe.onload = this.step_func_done(function () {
51 assert_resolve_url(iframe.contentDocument, location.href.replace("/docum ent-base-url.html", ""));
52 assert_equals(iframe.contentDocument.baseURI, document.baseURI, "The doc ument base URL should be the creator document's base URL.");
53 });
54 iframe.setAttribute("src", "about:blank");
55 document.body.appendChild(iframe);
56 }, "The fallback base URL of a document whose address is about:blank is the document base URL of the creator document.");
57
58 async_test(function () {
59 var iframe = document.createElement("iframe");
60 iframe.onload = this.step_func_done(function () {
61 var doc = iframe.contentDocument;
62 var base = doc.body.appendChild(doc.createElement("base"));
63 base.href = "sub/";
64 assert_resolve_url(doc, location.href.replace("/document-base-url.html", "/sub"));
65 assert_equals(doc.baseURI, document.baseURI.replace("/document-base-url. html", "/sub/"));
66 });
67 iframe.setAttribute("src", "about:blank");
68 document.body.appendChild(iframe);
69 }, "about:blank with a base element.");
70
71 async_test(function () {
72 var iframe = document.createElement("iframe");
73 iframe.onload = this.step_func_done(function () {
74 assert_resolve_url(iframe.contentDocument, location.href.replace("/docum ent-base-url.html", ""));
75 assert_equals(iframe.contentDocument.baseURI, document.baseURI, "The doc ument base URL should be the containing document's base URL.");
76 });
77 iframe.setAttribute("srcdoc", "<p>foobar</p>");
78 document.body.appendChild(iframe);
79 }, "The fallback base URL of an iframe srcdoc document is the document base URL of the document's browsing context's browsing context container's document." );
80
81 async_test(function () {
82 var iframe = document.createElement("iframe");
83 iframe.onload = this.step_func_done(function () {
84 var doc = iframe.contentDocument;
85 assert_resolve_url(doc, location.href.replace("/document-base-url.html", "/sub"));
86 assert_equals(doc.baseURI, document.baseURI.replace("/document-base-url. html", "/sub/"),
87 "The srcdoc document's base URL should be set by the <base > tag.");
88 });
89 iframe.setAttribute("srcdoc", "<base href='sub/'><p>foobar</p>");
90 document.body.appendChild(iframe);
91 }, "The base URL of an iframe srcdoc document with a <base> tag should be se t by that tag.");
92 </script>
93 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698