summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples/api/messaging/timer/page.js
blob: bdbf9bf9568eec5395242b45fd52cadf3c7d1323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

chrome.runtime.onConnect.addListener(function(port) {
  port.onMessage.addListener(function(msg) {
    port.postMessage({counter: msg.counter+1});
  });
});

chrome.extension.onRequest.addListener(
  function(request, sender, sendResponse) {
    sendResponse({counter: request.counter+1});
  });