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

Side by Side Diff: chrome/test/data/extensions/api_test/declarative/api/background.js

Issue 10257006: Move Declarative Web Request API out of experimental and make it a feature (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 7 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 declarative = chrome.experimental.declarative; 5 var declarative = chrome.declarative;
6 6
7 var RequestMatcher = chrome.experimental.webRequest.RequestMatcher; 7 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher;
8 var CancelRequest = chrome.experimental.webRequest.CancelRequest; 8 var CancelRequest = chrome.declarativeWebRequest.CancelRequest;
9 var RedirectRequest = chrome.experimental.webRequest.RedirectRequest; 9 var RedirectRequest = chrome.declarativeWebRequest.RedirectRequest;
10 10
11 var inputRule0 = { 11 var inputRule0 = {
12 // No 'id', this should be filled by the API. 12 // No 'id', this should be filled by the API.
13 conditions: [new RequestMatcher({url: {hostPrefix: "test1"}}), 13 conditions: [new RequestMatcher({url: {hostPrefix: "test1"}}),
14 new RequestMatcher({url: {hostPrefix: "test2"}})], 14 new RequestMatcher({url: {hostPrefix: "test2"}})],
15 actions: [new CancelRequest(), 15 actions: [new CancelRequest(),
16 new RedirectRequest({redirectUrl: "http://foobar.com"})] 16 new RedirectRequest({redirectUrl: "http://foobar.com"})]
17 // No 'priority', this should be filled by the API. 17 // No 'priority', this should be filled by the API.
18 } 18 }
19 19
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // "actions" is missing but not optional. 54 // "actions" is missing but not optional.
55 }; 55 };
56 56
57 var invalidRule1 = { 57 var invalidRule1 = {
58 conditions: [new RequestMatcher({url: {hostPrefix: "test1"}})], 58 conditions: [new RequestMatcher({url: {hostPrefix: "test1"}})],
59 // "actions" contains an invalid action (separate test because this validation 59 // "actions" contains an invalid action (separate test because this validation
60 // happens on a different code path). 60 // happens on a different code path).
61 actions: [{key: "value"}] 61 actions: [{key: "value"}]
62 }; 62 };
63 63
64 var testEvent = chrome.experimental.webRequest.onRequest; 64 var testEvent = chrome.declarativeWebRequest.onRequest;
65 65
66 chrome.test.runTests([ 66 chrome.test.runTests([
67 // Add adding two simple rules and check that their optional fields are set 67 // Add adding two simple rules and check that their optional fields are set
68 // correctly in the call back function. 68 // correctly in the call back function.
69 function testAddRules() { 69 function testAddRules() {
70 var callback = function(rules) { 70 var callback = function(rules) {
71 chrome.test.assertNoLastError(); 71 chrome.test.assertNoLastError();
72 chrome.test.assertEq(2, rules.length); 72 chrome.test.assertEq(2, rules.length);
73 // API should have generated id and priority fields. 73 // API should have generated id and priority fields.
74 chrome.test.assertTrue("id" in rules[0]); 74 chrome.test.assertTrue("id" in rules[0]);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // on page unload. 192 // on page unload.
193 function testAddRules() { 193 function testAddRules() {
194 var callback = function(rules) { 194 var callback = function(rules) {
195 chrome.test.assertNoLastError(); 195 chrome.test.assertNoLastError();
196 chrome.test.assertEq(1, rules.length); 196 chrome.test.assertEq(1, rules.length);
197 chrome.test.succeed(); 197 chrome.test.succeed();
198 }; 198 };
199 testEvent.addRules([inputRule0], callback); 199 testEvent.addRules([inputRule0], callback);
200 }, 200 },
201 ]); 201 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698