bug 603824: change panel docs reference from sendMessage to postMessage, which is the actual name of the method; r=adw
authorMyk Melez <myk@mozilla.org>
Tue, 19 Oct 2010 16:55:46 -0700
changeset 887 bb651f9b6f092dca29f79ae223ee67a31d2e3951
parent 886 895e79514ce608c6d1b56132ed48d22854d12c79
child 888 173d56fa8cc1c5622eae70f1ae88ef789de4722b
push id391
push usermyk@mozilla.com
push dateTue, 19 Oct 2010 23:55:52 +0000
reviewersadw
bugs603824
bug 603824: change panel docs reference from sendMessage to postMessage, which is the actual name of the method; r=adw
packages/addon-kit/docs/panel.md
packages/addon-kit/tests/test-panel.js
--- a/packages/addon-kit/docs/panel.md
+++ b/packages/addon-kit/docs/panel.md
@@ -201,23 +201,21 @@ the window object for the page has been 
 them once the DOM content of the page has been loaded.
 </api>
 
 <api name="onMessage">
 @property {array}
 Functions to call when a content script sends the panel a message.
 </api>
 
-<api name="sendMessage">
+<api name="postMessage">
 @method
 Send a message to the content scripts.
 @param message {string,number,object,array,boolean}
 The message to send.  Must be stringifiable to JSON.
-@param [callback] {function}
-A function the content scripts can call to respond to the message.  Optional.
 </api>
 
 <api name="show">
 @method
 Display the panel.
 @param [anchor] {DOMElement}
 The element to which the panel should be anchored (i.e. appear connected).
 If not specified, panels are centered relative to the most recent (frontmost)
--- a/packages/addon-kit/tests/test-panel.js
+++ b/packages/addon-kit/tests/test-panel.js
@@ -1,21 +1,29 @@
 let panels = require('panel');
 let URL = require("url").URL;
 let tests = {}, panels, Panel;
 
 tests.testPanel = function(test) {
   test.waitUntilDone();
   let panel = panels.add(Panel({
     contentURL: "about:buildconfig",
-    contentScript: "postMessage('')",
+    contentScript: "postMessage(1); on('message', function() postMessage(2));",
     onMessage: function (message) {
-      panels.remove(panel);
-      test.pass("The panel was loaded.");
-      test.done();
+      switch(message) {
+        case 1:
+          test.pass("The panel was loaded.");
+          panel.postMessage('');
+          break;
+        case 2:
+          test.pass("The panel posted a message and received a response.");
+          panels.remove(panel);
+          test.done();
+          break;
+      }
     }
   }));
 };
 
 tests.testShowHidePanel = function(test) {
   test.waitUntilDone();
   let panel = panels.add(Panel({
     contentScript: "postMessage('')",
@@ -179,10 +187,8 @@ if (panelSupported) {
   for (let test in tests)
     exports[test] = tests[test];
 }
 else {
   exports.testPanelNotSupported = function(test) {
     test.pass("The panel module is not supported on this app.");
   }
 }
-
-