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

Unified Diff: third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-method.html

Issue 2297483002: Make XMLHttpRequest.open() throw for invalid URLs (Closed)
Patch Set: Addressed #12 Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-url.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-method.html
diff --git a/third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-method.html b/third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-method.html
new file mode 100644
index 0000000000000000000000000000000000000000..885a533433859374dea178c84ef8531d527e0d14
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-method.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ const NON_TOKEN_METHODS = [
+ '',
+ 'test\r\nfoobar',
+ ' ',
+ 'A A',
+ '"',
+ '(',
+ ')',
+ ',',
+ '/',
+ ':',
+ ';',
+ '<',
+ '=',
+ '>',
+ '?',
+ '@',
+ '[',
+ '\\',
+ ']',
+ '{',
+ '}'
+ ];
+
+ for (let method of NON_TOKEN_METHODS) {
+ const xhr = new XMLHttpRequest();
+ assert_throws('SyntaxError', () => {
+ xhr.open(method, '/');
+ }, 'open() should throw for a SyntaxError for method "' + method +
+ '" which does not conform to the token ABNF');
+ }
+}, 'Method strings that are not token');
+
+test(() => {
+ const FORBIDDEN_METHODS = [
+ 'CONNECT',
+ 'connect',
+ 'Connect',
+ 'TRACE',
+ 'TRACK'
+ ];
+
+ for (let method of FORBIDDEN_METHODS) {
+ const xhr = new XMLHttpRequest();
+ assert_throws('SecurityError', () => {
+ xhr.open(method, '/');
+ }, 'open() should throw a SecurityError for a forbidden method "' + method + '"');
+ }
+}, 'Forbidden methods');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/xmlhttprequest/invalid-url.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698