blob: c60ba3293855390bbbad7c4440940792eeea18aa [file] [log] [blame]
* Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
* @description This test makes sure that navigator.registerProtocolHandler
* throws the proper exceptions and has no-op default implementation.
import "dart:html";
import "../../../testcommon.dart";
main() {
var invalid_protocols = ['http', 'https', 'file', 'web+'];
invalid_protocols.forEach((protocol) {
debug('invalid protocol: $protocol');
shouldThrow(() {
.registerProtocolHandler(protocol, "invalid protocol %s", "title");
}, (e) => e is DomException && == DomException.SECURITY);
var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto', 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', 'wtai', 'xmpp'];
valid_protocols.forEach((protocol) {
debug('valid protocol: $protocol');
.registerProtocolHandler(protocol, "valid protocol %s", "title");
var invalid_urls = ["", "%S"];
invalid_urls.forEach((url) {
debug('invalid url: $url');
shouldThrow(() {
window.navigator.registerProtocolHandler('web+myprotocol', url, 'title');
}, (e) => e is DomException && == DomException.SYNTAX);
// Test that the API has default no-op implementation.
window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title");