- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / managed_extension2 / background.js
1 // Copyright (c) 2013 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 var validate = function(policy) {
6   // This is the policy set by component_cloud_policy_browsertest.cc.
7   if (JSON.stringify(policy) == '{"Another":"turn_it_off"}')
8     chrome.test.sendMessage('ok');
9   else
10     chrome.test.sendMessage('fail');
11 }
12
13 // Get the initial policy, in case it was fetched before the extension started.
14 chrome.storage.managed.get(function(policy) {
15   if (JSON.stringify(policy) == '{}') {
16     // Start listening for the update event.
17     chrome.storage.onChanged.addListener(function(changes, namespace) {
18       if (namespace == 'managed') {
19         // Get all the policies and validate them.
20         chrome.storage.managed.get(validate);
21       }
22     });
23   } else {
24     validate(policy);
25   }
26 });