3 <p>This test makes sure that navigator.unregisterProtocolHandler throws the proper exceptions and has no-op default implementation.</p>
4 <pre id="console"></pre>
7 testRunner.dumpAsText();
11 var c = document.getElementById('console')
12 c.appendChild(document.createTextNode(str + '\n'));
15 if (window.navigator.unregisterProtocolHandler)
16 debug('Pass: window.navigator.unregisterProtocolHandler is defined.');
18 debug('Fail: window.navigator.unregisterProtocolHandler is not defined.');
20 var invalid_protocols = ['http', 'https', 'file'];
21 invalid_protocols.forEach(function (protocol) {
22 var succeeded = false;
24 window.navigator.unregisterProtocolHandler(protocol, "invalid protocol %s", "title");
26 succeeded = 'SecurityError' == e.name;
30 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exception.');
32 debug('Fail: Invalid protocol "' + protocol + '" allowed.');
35 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto', 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', 'wtai', 'xmpp'];
36 valid_protocols.forEach(function (protocol) {
37 var succeeded = false;
39 window.navigator.unregisterProtocolHandler(protocol, "valid protocol %s", "title");
46 debug('Pass: Valid protocol "' + protocol + '" allowed.');
48 debug('Fail: Valid protocol "' + protocol + '" failed.');
51 var invalid_urls = ["", "%S"];
52 invalid_urls.forEach(function (url) {
53 var succeeded = false;
55 window.navigator.unregisterProtocolHandler('web+myprotocol', url, 'title');
57 succeeded = 'SyntaxError' == e.name;
61 debug('Pass: Invalid url "' + url + '" threw SyntaxError exception.');
63 debug('Fail: Invalid url "' + url + '" allowed.');
66 // Test that the API has default no-op implementation.
69 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title");
75 debug('Pass: Valid call succeeded.');
77 debug('Fail: Invalid call did not succeed.');