Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / webrequest_permissions / split / background.js
blobb1df796fcfc92bd428153a370a6593d005b28d5a
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.
5 chrome.declarativeWebRequest.onRequest.removeRules();
6 var rule = {
7   conditions: [
8     new chrome.declarativeWebRequest.RequestMatcher(
9         {url: {pathContains: '.html'}}),
10   ],
11   actions: [],
13 if (chrome.extension.inIncognitoContext) {
14   rule.actions = [
15     new chrome.declarativeWebRequest.RedirectRequest(
16         {'redirectUrl': 'data:text/plain,redirected2'})
17   ];
18 } else {
19   rule.actions = [
20     new chrome.declarativeWebRequest.RedirectRequest(
21         {'redirectUrl': 'data:text/plain,redirected1'})
22   ];
24 function notifyDone() {
25   if (chrome.extension.inIncognitoContext)
26     chrome.test.sendMessage("done_incognito");
27   else
28     chrome.test.sendMessage("done");
30 chrome.declarativeWebRequest.onRequest.addRules([rule], notifyDone);