Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xmlhttprequest / xmlhttprequest-open-exceptions.html
blob89143b580f46b85bff56fe417e8daf1498b07103
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-Security-Policy" content="connect-src http://example.com">
5 </head>
6 <body>
7 <script src="../../resources/js-test.js"></script>
8 <script>
9 description("This tests that exceptions thrown by XHR.open() have reasonable messages.");
11 var xhrException;
12 try {
13 var xhr = new XMLHttpRequest();
14 xhr.open("TRACE", "http://example.com/");
15 testFailed("xhr.open should throw an exception with a forbidden method type.");
16 } catch (e) {
17 xhrException = e;
18 shouldBeEqualToString("xhrException.message", "Failed to execute 'open' on 'XMLHttpRequest': 'TRACE' HTTP method is unsupported.");
21 try {
22 var xhr = new XMLHttpRequest();
23 xhr.open("GET", "http://not.example.com/");
24 testFailed("xhr.open to a URL blocked by CSP should throw an exception.");
25 } catch (e) {
26 xhrException = e;
27 shouldBeEqualToString("xhrException.message", "Failed to execute 'open' on 'XMLHttpRequest': Refused to connect to 'http://not.example.com/' because it violates the document's Content Security Policy.");
30 var badString = { toString: function() { throw "Exception in toString()"; } };
31 var xhr = new XMLHttpRequest();
32 shouldBe("xhr.readyState", "XMLHttpRequest.UNSENT");
33 shouldThrow("xhr.open('GET', 'resources/xmlhttprequest-get-data.xml', true, badString, 'password');", "'Exception in toString()'");
34 shouldBe("xhr.readyState", "XMLHttpRequest.UNSENT");
35 shouldThrow("xhr.open('GET', 'resources/xmlhttprequest-get-data.xml', true, 'username', badString);", "'Exception in toString()'");
36 shouldBe("xhr.readyState", "XMLHttpRequest.UNSENT");
37 </script>
38 </body>
39 </html>