[Pkg-mozext-commits] [requestpolicy] 192/280: sendSyncMessage: check if there is an answer

David Prévot taffit at moszumanska.debian.org
Sat May 2 20:30:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 79c7742a9d57e7f028ab3b59fd147ffed9d6f057
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sat Jan 31 14:41:03 2015 +0100

    sendSyncMessage: check if there is an answer
    
    When using sendSyncMessage() and waiting for an answer,
    it should be checked whether there is an answer at all.
    
    In the case of "notifyDocumentLoaded" this could happen
    if the overlay failed to add a message listener for that
    message.
---
 src/content/ui/frame.dom-content-loaded.js | 35 ++++++++++++++++++------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/content/ui/frame.dom-content-loaded.js b/src/content/ui/frame.dom-content-loaded.js
index 3563cc3..341a845 100644
--- a/src/content/ui/frame.dom-content-loaded.js
+++ b/src/content/ui/frame.dom-content-loaded.js
@@ -67,20 +67,27 @@ let ManagerForDOMContentLoaded = (function() {
 
     onDocumentLoaded(doc);
 
-    // take only one answer. If there are more answers, they are ignored
-    // ==> there must be only one listener for 'notifyDocumentLoaded'
-    let [answer] = mm.sendSyncMessage(C.MM_PREFIX + "notifyDocumentLoaded",
-                                      {documentURI: doc.documentURI});
-    var blockedURIs = answer.blockedURIs;
-    //console.debug("Received " +
-    //              Object.getOwnPropertyNames(blockedURIs).length +
-    //              " blocked URIs.");
-
-    // Indicating blocked visible objects isn't an urgent task, so this should
-    // be done async.
-    Utils.runAsync(function() {
-      ManagerForBlockedContent.indicateBlockedVisibleObjects(doc, blockedURIs);
-    });
+    let answers = mm.sendSyncMessage(C.MM_PREFIX + "notifyDocumentLoaded",
+                                     {documentURI: doc.documentURI});
+    if (answers.length === 0) {
+      Logger.warning(Logger.TYPE_ERROR, 'There seems to be no message ' +
+                     'listener for "notifyDocumentLoaded".');
+    } else {
+      // take only one answer. If there are more answers, they are ignored
+      // ==> there must be only one listener for 'notifyDocumentLoaded'
+      let answer = answers[0];
+
+      var blockedURIs = answer.blockedURIs;
+      //console.debug("Received " +
+      //              Object.getOwnPropertyNames(blockedURIs).length +
+      //              " blocked URIs.");
+
+      // Indicating blocked visible objects isn't an urgent task, so this should
+      // be done async.
+      Utils.runAsync(function() {
+        ManagerForBlockedContent.indicateBlockedVisibleObjects(doc, blockedURIs);
+      });
+    }
 
 
     if (isActiveTopLevelDocument(doc)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list