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

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_declarative_permissions.js

Issue 14358004: Almost all actions in Declarative Web Request require all_urls host permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: All URLs -> all hosts; also rebased Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // See permissionless/rules.js for the rules that this test uses.
6
7 runTests([
8 // Test that it's possible to redirect within the same domain and port
9 // (ignoring the scheme) without host permissions.
10 function testRedirectSameDomain() {
11 ignoreUnexpected = true;
12 var testURL = getServerURL(
13 'files/extensions/api_test/webrequest/simpleLoad/a.html',
14 'www.a.com', 'https');
15 expect(
16 [
17 { label: 'onBeforeRedirect',
18 event: 'onBeforeRedirect',
19 details: {
20 url: testURL,
21 redirectUrl: getServerURL('files/nonexistent/redirected'),
22 statusCode: -1,
23 statusLine: '',
24 fromCache: false,
25 }
26 },
27 ],
28 [ ['onBeforeRedirect'] ]
29 );
30 navigateAndWait(testURL);
31 },
32
33 // Test that it's not possible to redirect to a different domain
34 // without host permissions on the original domain. We should still
35 // load the original URL.
36 function testCannotRedirectDifferentDomains() {
37 ignoreUnexpected = true;
38 var testURL = getServerURL(
39 'files/extensions/api_test/webrequest/simpleLoad/b.html');
40 expect(
41 [
42 { label: 'onCompleted',
43 event: 'onCompleted',
44 details: {
45 url: testURL,
46 fromCache: false,
47 ip: '127.0.0.1',
48 statusCode: 200,
49 statusLine: 'HTTP/1.0 200 OK',
50 }
51 },
52 ],
53 [ ['onCompleted'] ]
54 );
55 navigateAndWait(testURL);
56 },
57
58 // Test that it's possible to redirect by regex within the same
59 // domain and port (ignoring the scheme) without host permissions.
60 function testRedirectByRegexSameDomain() {
61 ignoreUnexpected = true;
62 var testURL = getServerURL(
63 'files/extensions/api_test/webrequest/simpleLoad/fake.html');
64 expect(
65 [
66 { label: 'onBeforeRedirect',
67 event: 'onBeforeRedirect',
68 details: {
69 url: testURL,
70 redirectUrl: getServerURL(
71 'files/extensions/api_test/webrequest/simpleLoad/b.html'),
72 statusCode: -1,
73 statusLine: '',
74 fromCache: false,
75 }
76 },
77 ],
78 [ ['onBeforeRedirect'] ]
79 );
80 navigateAndWait(testURL);
81 },
82
83 // Test that it's possible to redirect to a blank page/image
84 // without host permissions.
85 function testRedirectToEmpty() {
86 var testURL = getServerURL('files/nonexistent/blank.html');
87 ignoreUnexpected = true;
88 expect(
89 [
90 { label: 'onBeforeRedirect',
91 event: 'onBeforeRedirect',
92 details: {
93 url: testURL,
94 redirectUrl: 'data:text/html,',
95 statusCode: -1,
96 statusLine: '',
97 fromCache: false,
98 }
99 },
100 ],
101 [ ['onBeforeRedirect'] ]
102 );
103 navigateAndWait(testURL);
104 },
105
106 // Test that it's possible to cancel a request without host permissions.
107 function testCancelRequest() {
108 ignoreUnexpected = true;
109 var testURL = getServerURL('files/nonexistent/cancel.html');
110 expect(
111 [
112 { label: 'onErrorOccurred',
113 event: 'onErrorOccurred',
114 details: {
115 url: testURL,
116 fromCache: false,
117 error: 'net::ERR_BLOCKED_BY_CLIENT'
118 }
119 },
120 ],
121 [ ['onErrorOccurred'] ]
122 );
123 navigateAndWait(testURL);
124 },
125
126 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698