| OLD | NEW |
| 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 document.body.innerHTML = ""; | 5 document.body.innerHTML = ""; |
| 6 | 6 |
| 7 function addButton(name, cb) { | 7 function addButton(name, cb) { |
| 8 var a = document.createElement("button"); | 8 var a = document.createElement("button"); |
| 9 a.innerText = name; | 9 a.innerText = name; |
| 10 a.onclick = cb; | 10 a.onclick = cb; |
| 11 document.body.appendChild(document.createElement("br")); | 11 document.body.appendChild(document.createElement("br")); |
| 12 document.body.appendChild(a); | 12 document.body.appendChild(a); |
| 13 } | 13 } |
| 14 | 14 |
| 15 function log(str) { | 15 function log(str) { |
| 16 console.log(str); | 16 console.log(str); |
| 17 logDiv.innerHTML += str + "<br>"; | 17 logDiv.innerHTML += str + "<br>"; |
| 18 } | 18 } |
| 19 | 19 |
| 20 addButton("Clear logs", function() { | 20 addButton("Clear logs", function() { |
| 21 logDiv.innerHTML = ""; | 21 logDiv.innerHTML = ""; |
| 22 }); | 22 }); |
| 23 | 23 |
| 24 addButton("Send message with delayed response", function() { | 24 addButton("Send message with delayed response", function() { |
| 25 chrome.extension.sendMessage({delayedResponse: true}, function(response) { | 25 chrome.runtime.sendMessage({delayedResponse: true}, function(response) { |
| 26 log("Background page responded: " + response); | 26 log("Background page responded: " + response); |
| 27 }); | 27 }); |
| 28 }); | 28 }); |
| 29 | 29 |
| 30 addButton("Show counters", function() { | 30 addButton("Show counters", function() { |
| 31 chrome.extension.sendMessage({getCounters: true}, function(response) { | 31 chrome.runtime.sendMessage({getCounters: true}, function(response) { |
| 32 log("In-memory counter is: " + response.counter); | 32 log("In-memory counter is: " + response.counter); |
| 33 log("Persisted counter is: " + response.persistentCounter); | 33 log("Persisted counter is: " + response.persistentCounter); |
| 34 }); | 34 }); |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 addButton("Set an alarm", function() { | 37 addButton("Set an alarm", function() { |
| 38 chrome.extension.sendMessage({setAlarm: true}); | 38 chrome.runtime.sendMessage({setAlarm: true}); |
| 39 }); | 39 }); |
| 40 | 40 |
| 41 chrome.extension.onMessage.addListener(function(msg, _, sendResponse) { | 41 chrome.runtime.onMessage.addListener(function(msg, _, sendResponse) { |
| 42 log("Got message from background page: " + msg); | 42 log("Got message from background page: " + msg); |
| 43 }); | 43 }); |
| 44 | 44 |
| 45 var logDiv = document.createElement("div"); | 45 var logDiv = document.createElement("div"); |
| 46 logDiv.style.border = "1px dashed black"; | 46 logDiv.style.border = "1px dashed black"; |
| 47 document.body.appendChild(document.createElement("br")); | 47 document.body.appendChild(document.createElement("br")); |
| 48 document.body.appendChild(logDiv); | 48 document.body.appendChild(logDiv); |
| 49 | 49 |
| 50 log("Ready."); | 50 log("Ready."); |
| OLD | NEW |