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

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_declarative2.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
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 onRequest = chrome.declarativeWebRequest.onRequest; 5 var onRequest = chrome.declarativeWebRequest.onRequest;
6 var AddResponseHeader = 6 var AddResponseHeader =
7 chrome.declarativeWebRequest.AddResponseHeader; 7 chrome.declarativeWebRequest.AddResponseHeader;
8 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher; 8 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher;
9 var CancelRequest = chrome.declarativeWebRequest.CancelRequest; 9 var CancelRequest = chrome.declarativeWebRequest.CancelRequest;
10 var RedirectByRegEx = chrome.declarativeWebRequest.RedirectByRegEx; 10 var RedirectByRegEx = chrome.declarativeWebRequest.RedirectByRegEx;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 "result.pass = (cookieMap.passedCookie === 'Foo') &&" + 247 "result.pass = (cookieMap.passedCookie === 'Foo') &&" +
248 " (cookieMap.addedCookie === 'Foo') &&" + 248 " (cookieMap.addedCookie === 'Foo') &&" +
249 " (cookieMap.editedCookie === 'bar') &&" + 249 " (cookieMap.editedCookie === 'bar') &&" +
250 " !cookieMap.hasOwnProperty('deletedCookie');" + 250 " !cookieMap.hasOwnProperty('deletedCookie');" +
251 "chrome.extension.sendRequest(result);"}); 251 "chrome.extension.sendRequest(result);"});
252 }); 252 });
253 } 253 }
254 ); 254 );
255 }, 255 },
256 256
257 function testPermission() {
258 // Test that a redirect is ignored if the extension has no permission.
259 // we load a.html from a.com and issue an XHR to b.com, which is not
260 // contained in the extension's host permissions. Therefore, we cannot
261 // redirect the XHR from b.com to a.com, and the request returns the
262 // original file from b.com.
263 ignoreUnexpected = true;
264 expect();
265 onRequest.addRules(
266 [ {'conditions': [new RequestMatcher({'url': {'pathContains': ".json"}})],
267 'actions': [
268 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]}
269 ],
270 function() {
271 var callback = chrome.test.callbackAdded();
272 navigateAndWait(getURL("simpleLoad/a.html"), function() {
273 var asynchronous = false;
274 var req = new XMLHttpRequest();
275 req.onreadystatechange = function() {
276 if (this.readyState != this.DONE)
277 return;
278 // "{}" is the contents of the file at getURLHttpXHRData().
279 if (this.status == 200 && this.responseText == "{}\n") {
280 callback();
281 } else {
282 chrome.test.fail("Redirect was not prevented. Status: " +
283 this.status + ", responseText: " + this.responseText);
284 }
285 };
286 req.open("GET", getURLHttpXHRData(), asynchronous);
287 req.send();
288 });
289 }
290 );
291 },
292
293 function testRequestHeaders() { 257 function testRequestHeaders() {
294 ignoreUnexpected = true; 258 ignoreUnexpected = true;
295 expect( 259 expect(
296 [ 260 [
297 { label: "onErrorOccurred", 261 { label: "onErrorOccurred",
298 event: "onErrorOccurred", 262 event: "onErrorOccurred",
299 details: { 263 details: {
300 url: getURLHttpSimple(), 264 url: getURLHttpSimple(),
301 fromCache: false, 265 fromCache: false,
302 error: "net::ERR_BLOCKED_BY_CLIENT" 266 error: "net::ERR_BLOCKED_BY_CLIENT"
(...skipping 11 matching lines...) Expand all
314 }, 278 },
315 'requestHeaders': [{ nameContains: "" }], 279 'requestHeaders': [{ nameContains: "" }],
316 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }] 280 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }]
317 })], 281 })],
318 'actions': [new CancelRequest()]} 282 'actions': [new CancelRequest()]}
319 ], 283 ],
320 function() {navigateAndWait(getURLHttpSimple());} 284 function() {navigateAndWait(getURLHttpSimple());}
321 ); 285 );
322 }, 286 },
323 ]); 287 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698