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

Unified Diff: LayoutTests/fast/dom/register-protocol-handler.html

Issue 23135009: Improve IDB module's SecurityError messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: test Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/register-protocol-handler.html
diff --git a/LayoutTests/fast/dom/register-protocol-handler.html b/LayoutTests/fast/dom/register-protocol-handler.html
index edd02f9aad6df55e27529fd4da22acd8d579de94..2836a836eea9be51363807cde7e66e8ad5d23c15 100644
--- a/LayoutTests/fast/dom/register-protocol-handler.html
+++ b/LayoutTests/fast/dom/register-protocol-handler.html
@@ -1,80 +1,33 @@
<html>
<body>
-<p>This test makes sure that navigator.registerProtocolHandler throws the proper exceptions and has no-op default implementation.</p>
-<pre id="console"></pre>
+<script src="../js/resources/js-test-pre.js"></script>
<script>
-if (window.testRunner)
- testRunner.dumpAsText();
+ description("This test makes sure that navigator.registerProtocolHandler throws the proper exceptions and has no-op default implementation.");
-function debug(str)
-{
- var c = document.getElementById('console')
- c.appendChild(document.createTextNode(str + '\n'));
-}
-
-if (window.navigator.registerProtocolHandler)
- debug('Pass: window.navigator.registerProtocolHandler is defined.');
-else
- debug('Fail: window.navigator.registerProtocolHandler is not defined.');
-
-var invalid_protocols = ['http', 'https', 'file', 'web+'];
-invalid_protocols.forEach(function (protocol) {
- var succeeded = false;
- try {
- window.navigator.registerProtocolHandler(protocol, "invalid protocol %s", "title");
- } catch (e) {
- succeeded = 'SecurityError' == e.name;
- }
-
- if (succeeded)
- debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exception.');
- else
- debug('Fail: Invalid protocol "' + protocol + '" allowed.');
-});
-
-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(function (protocol) {
- var succeeded = false;
- try {
- window.navigator.registerProtocolHandler(protocol, "valid protocol %s", "title");
- succeeded = true;
- } catch (e) {
- succeeded = false;
- }
-
- if (succeeded)
- debug('Pass: Valid protocol "' + protocol + '" allowed.');
+ if (window.navigator.registerProtocolHandler)
+ testPassed('window.navigator.registerProtocolHandler is defined.');
else
- debug('Fail: Valid protocol "' + protocol + '" failed.');
-});
-
-var invalid_urls = ["", "%S"];
-invalid_urls.forEach(function (url) {
- var succeeded = false;
- try {
- window.navigator.registerProtocolHandler('web+myprotocol', url, 'title');
- } catch (e) {
- succeeded = 'SyntaxError' == e.name;
- }
-
- if (succeeded)
- debug('Pass: Invalid url "' + url + '" threw SyntaxError exception.');
- else
- debug('Fail: Invalid url "' + url + '" allowed.');
-});
-
-// Test that the API has default no-op implementation.
-var succeeded = true;
-try {
- window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title");
-} catch (e) {
- succeeded = false;
-}
-
-if (succeeded)
- debug('Pass: Valid call succeeded.');
-else
- debug('Fail: Invalid call did not succeed.');
+ testFailed('window.navigator.registerProtocolHandler is not defined.');
+
+ var protocol;
+ var invalid_protocols = ['http', 'https', 'file', 'web+'];
+ invalid_protocols.forEach(function (protocol) {
+ shouldThrow("window.navigator.registerProtocolHandler('" + protocol + "', 'invalid protocol %s', 'title');");
+ });
+
+ 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(function (protocol) {
+ shouldNotThrow("window.navigator.registerProtocolHandler('" + protocol + "', 'valid protocol %s', 'title');");
+ });
+
+ var invalid_urls = ["", "%S"];
+ invalid_urls.forEach(function (url) {
+ shouldThrow("window.navigator.registerProtocolHandler('web+myprotocol', '" + url + "', 'title');");
+ });
+
+ // Test that the API has default no-op implementation.
+ shouldNotThrow("window.navigator.registerProtocolHandler('web+myprotocol', '%s', 'title');");
</script>
+<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/register-protocol-handler-expected.txt » ('j') | Source/modules/indexeddb/IDBFactory.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698