Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / settings / protocol_handler.html
blobde2fb518413538ee53c77d1c0821b90a2dc03f0d
1 <html>
2 <head>
3 <title>Protocol Handler Test - Register</title>
4 <script type="text/javascript">
5 function registerCustomHandler() {
6 var custom_protocol = "web+search";
7 var query_value = custom_protocol + ":test";
8 var query_key = "q";
9 var url = document.URL + "?" + query_key + "=%s";
10 var title = "Example Search";
12 navigator.registerProtocolHandler(
13 custom_protocol, url, title);
14 var element = document.getElementById('test_protocol');
15 element.innerText = query_value;
16 element.setAttribute('href', query_value);
18 return {"protocol": custom_protocol, "url": url, "title": title,
19 "query_key": query_key, "query_value": query_value};
22 function registerMailClient() {
23 var mail_protocol = "mailto";
24 var query_value = mail_protocol + ":example@examplemail.com";
25 var query_key = "source";
26 var url = document.URL + "?" + query_key + "=%s";
27 var title = "ExampleMailClient";
29 navigator.registerProtocolHandler(mail_protocol, url, title);
30 return {"protocol": mail_protocol, "url": url, "title": title,
31 "query_key": query_key, "query_value": query_value};
34 // Analyzes the query substring (if any) of the URL and confirms
35 // whether it's expected.
36 function doesQueryConformsToProtocol(query_key, query_value) {
37 var query = window.location.search.substring(1);
38 var arg_list = query.split("&");
40 if(arg_list.length != 1) return false;
41 var variable_value = arg_list[0].split("=");
42 if((variable_value[0] != query_key) ||
43 (unescape(variable_value[1]) != query_value))
44 return false;
45 return true;
47 </script>
48 </head>
49 <body>
50 <div>
51 <a id="test_protocol"></a>
52 </div>
53 <div>
54 <a id="test_mail_protocol" href="mailto:example@examplemail.com">mailto:example@examplemail.com</a>
55 </div>
56 </body>
57 </html>