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

Side by Side Diff: chrome/test/data/extensions/api_test/proxy/events/invalid_proxy.html

Issue 8757010: Move another block of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <script> 1 <!--
2 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 // Use of this source code is governed by a BSD-style license that can be 3 * source code is governed by a BSD-style license that can be found in the
4 // found in the LICENSE file. 4 * LICENSE file.
5 5 -->
6 // proxy api test 6 <script src="invalid_proxy.js"></script>
7 // browser_tests.exe --gtest_filter=ProxySettingsApiTest.ProxyEventsInvalidProxy
8
9 var expected_error = {
10 error: "net::ERR_PROXY_CONNECTION_FAILED",
11 details: "",
12 fatal: true
13 };
14 var empty_json_url = "";
15
16 function test() {
17 // Install error handler and get the test server config.
18 chrome.proxy.onProxyError.addListener(function (error) {
19 chrome.test.assertEq(expected_error, error);
20 chrome.test.notifyPass();
21 });
22 chrome.test.getConfig(readConfigAndSetProxy);
23 }
24
25 function readConfigAndSetProxy(test_config) {
26 // Construct the URL used for XHRs and set the proxy settings.
27 empty_json_url = "http://127.0.0.1:" +
28 test_config.testServer.port +
29 "/files/extensions/api_test/proxy/events/empty.json";
30
31 // Set an invalid proxy and fire of a XHR. This should trigger proxy errors.
32 // There may be any number of proxy errors, as systems like safe browsing
33 // might start network traffic as well.
34 var rules = {
35 singleProxy: { host: "does.not.exist" }
36 };
37 var config = { rules: rules, mode: "fixed_servers" };
38 chrome.proxy.settings.set({'value': config}, sendFailingXHR);
39 }
40
41 function sendFailingXHR() {
42 var req = new XMLHttpRequest();
43 req.open("GET", empty_json_url, true);
44 req.onload = function () {
45 chrome.test.notifyFail("proxy settings should not work");
46 }
47 req.onerror = testDone;
48 req.send(null);
49 }
50
51 function testDone() {
52 // Do nothing. The test success/failure is decided in the event handler.
53 }
54
55 test();
56 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698