OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var assertEq = chrome.test.assertEq; | 5 var assertEq = chrome.test.assertEq; |
6 var fail = chrome.test.fail; | 6 var fail = chrome.test.fail; |
7 var succeed = chrome.test.succeed; | 7 var succeed = chrome.test.succeed; |
8 | 8 |
9 var DEFAULT_EXPECTED_ERROR = "Not available for platform apps."; | 9 var DEFAULT_EXPECTED_ERROR = "Not available for platform apps."; |
10 | 10 |
11 function assertThrowsError(method, opt_expectedError) { | 11 function assertThrowsError(method, opt_expectedError) { |
12 try { | 12 try { |
13 method(); | 13 method(); |
14 fail("error not thrown"); | 14 fail("error not thrown"); |
15 } catch (e) { | 15 } catch (e) { |
16 assertEq(e.message || e, opt_expectedError || DEFAULT_EXPECTED_ERROR); | 16 assertEq(opt_expectedError || DEFAULT_EXPECTED_ERROR, e.message || e); |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 chrome.test.runTests([ | 20 chrome.test.runTests([ |
21 function testDocumentOpen() { | 21 function testDocumentOpen() { |
22 assertThrowsError(document.open); | 22 assertThrowsError(document.open); |
23 succeed(); | 23 succeed(); |
24 }, | 24 }, |
25 | 25 |
26 function testDocumentClose() { | 26 function testDocumentClose() { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 }, | 134 }, |
135 | 135 |
136 function testSyncXhr() { | 136 function testSyncXhr() { |
137 var xhr = new XMLHttpRequest(); | 137 var xhr = new XMLHttpRequest(); |
138 assertThrowsError(function() { | 138 assertThrowsError(function() { |
139 xhr.open('GET', 'data:should not load', false); | 139 xhr.open('GET', 'data:should not load', false); |
140 }, 'INVALID_ACCESS_ERR: DOM Exception 15'); | 140 }, 'INVALID_ACCESS_ERR: DOM Exception 15'); |
141 succeed(); | 141 succeed(); |
142 } | 142 } |
143 ]); | 143 ]); |
OLD | NEW |