Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / tabs / connect / echo.js
blobc2a49285ddbb3a7ef0cc41dd1770efd9b2e11d6b
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.
5 // Content script that echoes back all messages.
6 // Posting a message with "GET" returns the name and # of connections opened.
7 var connections = 0;
9 chrome.runtime.onConnect.addListener(function onConnect(port) {
10 connections++;
11 port.onMessage.addListener(function onMessage(msg) {
12 if (msg == "GET") {
13 port.postMessage({"name": port.name, "connections": connections});
14 } else {
15 port.postMessage(msg);
17 });
18 });
20 chrome.extension.onRequest.addListener(function(request, sender, respond) {
21 respond(request);
22 });