Chromium Code Reviews| Index: tools/testing/extensions/chrome/ConsoleCollector/content.js |
| =================================================================== |
| --- tools/testing/extensions/chrome/ConsoleCollector/content.js (revision 0) |
| +++ tools/testing/extensions/chrome/ConsoleCollector/content.js (revision 0) |
| @@ -0,0 +1,17 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// This is the content page script. This runs in the context of the browser |
|
Emily Fortuna
2012/10/09 20:27:24
nit: but in some files you use the /** */ style no
|
| +// page, and communicates with the background page by relaying a getMessages |
| +// request, and the forwarding the messages back to the browser page as a |
| +// gotMessages message. |
| +window.addEventListener("message", function(event) { |
| + if (event.source == window && event.data == "getMessages") { |
| + // Log a special sentinel message to mark the end of the messages. |
| + console.log('getMessages/end'); |
| + chrome.extension.sendRequest({command: "getMessages"}, function(messages) { |
| + window.postMessage({ "type": "gotMessages", "messages" : messages}, "*"); |
| + }); |
| + } |
| +}, false); |