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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/open-with-invalid-argument-is-noop.html

Issue 2297483002: Make XMLHttpRequest.open() throw for invalid URLs (Closed)
Patch Set: Test that invalid open() is no-op Created 4 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: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/open-with-invalid-argument-is-noop.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/open-with-invalid-argument-is-noop.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/open-with-invalid-argument-is-noop.html
new file mode 100644
index 0000000000000000000000000000000000000000..638ddb833a6c6f935673e6f63138af27b3c61a3d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/open-with-invalid-argument-is-noop.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', 'resources/get.txt');
+ xhr.onload = t.step_func(() => {
+ assert_equals(xhr.responseText, 'PASS');
+ t.done();
+ });
+
+ assert_throws('SyntaxError', () => {
+ xhr.open('FOO BAR', 'nonexistent');
+ }, 'open() should throw for a SyntaxError for an invalid method');
+
+ xhr.send();
+}, 'open() with an invalid method is no-op');
+
+async_test(t => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', 'resources/get.txt');
+ xhr.onload = t.step_func(() => {
+ assert_equals(xhr.responseText, 'PASS');
+ t.done();
+ });
+
+ assert_throws('SecurityError', () => {
+ xhr.open('CONNECT', 'nonexistent');
+ }, 'open() should throw for a SecurityError for a forbidden method');
+
+ xhr.send();
+}, 'open() with a forbidden method is no-op');
+
+async_test(t => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', 'resources/get.txt');
+ xhr.onload = t.step_func(() => {
+ assert_equals(xhr.responseText, 'PASS');
+ t.done();
+ });
+
+ assert_throws('SyntaxError', () => {
+ xhr.open('GET', 'http://localhost:foobar/');
+ }, 'open() should throw for a SyntaxError for an invalid method');
yhirano 2016/09/01 07:02:42 wrong description
tyoshino (SeeGerritForStatus) 2016/09/01 10:19:41 Good catches. Fixed
+
+ xhr.send();
+}, 'open() with a forbidden method is no-op');
yhirano 2016/09/01 07:02:42 wrong name
tyoshino (SeeGerritForStatus) 2016/09/01 10:19:41 Done.
+</script>

Powered by Google App Engine
This is Rietveld 408576698