10 if (window
.testRunner
)
11 testRunner
.dumpAsText();
12 function emitFrameWithContents(contents
)
14 document
.write("<iframe src=\"data:text/html," + contents
+ "\"></iframe>");
16 function getRandomHost()
18 return "www." + Math
.floor(Math
.random() * 10000000000) + ".invalid";
20 function emitFrameForScheme(scheme
)
22 var host
= getRandomHost();
23 var contents
= "<meta http-equiv='x-dns-prefetch-control' content='on'>";
24 contents
+= "<a href='" + scheme
+ "//" + host
+ "'>" + host
+ "</a>";
25 emitFrameWithContents(contents
);
27 function emitFrameForHost(host
)
29 var contents
= "<meta http-equiv='x-dns-prefetch-control' content='on'>";
30 contents
+= "<a href='http:" + "//" + host
+ "'>" + host
+ "</a>";
31 emitFrameWithContents(contents
);
33 function emitFrameForManualDNSPrefetch(dnsPrefetchControl
)
35 var host
= getRandomHost();
37 if (dnsPrefetchControl
)
38 contents
+= "<meta http-equiv='x-dns-prefetch-control' content='" + dnsPrefetchControl
+ "'>";
39 contents
+= "<link rel='dns-prefetch' href='http://" + host
+ "'>" + host
;
40 emitFrameWithContents(contents
);
44 <p>This is a test of DNS prefetch control. It's considered a pass if it doesn't crash. It can also be used as
45 a manual test of DNS prefetch using a networking monitoring tool.
</p>
47 <p>The following frames contain links that are expected to trigger a DNS prefetch.
</p>
50 <script>emitFrameForManualDNSPrefetch("on")</script>
51 <script>emitFrameForManualDNSPrefetch("off")</script>
52 <script>emitFrameForScheme("http:")</script>
53 <script>emitFrameForScheme("https:")</script>
54 <script>emitFrameForScheme("ftp:")</script>
55 <script>emitFrameForHost("%")</script>
56 <iframe src=
"resources/dns-prefetch-control.php"></iframe>
57 <iframe src=
"resources/dns-prefetch-control.php?value=on"></iframe>
58 <iframe src=
"https://127.0.0.1:8443/misc/resources/dns-prefetch-control.php?value=on"></iframe>
61 <p style='clear: left'
>The following frames contain links that are not expected to cause a DNS prefetch.
</p>
64 <iframe src=
"resources/dns-prefetch-control.php?value=off"></iframe>
65 <iframe src=
"resources/dns-prefetch-control.php?value=foo"></iframe>
66 <iframe src=
"https://127.0.0.1:8443/misc/resources/dns-prefetch-control.php"></iframe>
67 <iframe src=
"https://127.0.0.1:8443/misc/resources/dns-prefetch-control.php?value=off"></iframe>
68 <iframe src=
"https://127.0.0.1:8443/misc/resources/dns-prefetch-control.php?value=foo"></iframe>
69 <iframe src=
"data:text/html,<meta http-equiv='x-dns-prefetch-control' value='off'><iframe src='http://127.0.0.1:8000/misc/resources/dns-prefetch-control.php'></iframe>"></iframe>
70 <iframe src=
"data:text/html,<meta http-equiv='x-dns-prefetch-control' value='on'><iframe src='https://127.0.0.1:8443/misc/resources/dns-prefetch-control.php'></iframe>"></iframe>