Firebreath 2.0 - Not able to load the plugin on the browser

86 views
Skip to first unread message

Debjit Das

unread,
Dec 23, 2016, 3:24:27 AM12/23/16
to firebreath-dev
Hi

I have created a plugin using Firebreath 2.0. I have also created  a test html page to test the plugin. However the javascript I wrote on the page (as was mentioned in a site) does not work. Given below is the content of the html page. What might have gone wrong? Is there any pre-requisite for running Firebreath 2.0 plugin on Chrome? Is there a step by step guide for this?

---------------------------------
<!DOCTYPE html>
<html>
<head>
<title>test page for object fbcontrol</title>

<script type="text/javascript">
var mimetype = "application/x-testplugin"
var plugin = null;
function initPlugin() {
    //Create a var that basically saves a random number to guarantee an unique identifier for a function. _plugin_ can be any other name.
    var callbackFn = "_plugin_" + Math.floor(Math.random() * 100000000);
    window[callbackFn] = function (data) {
      alert("trace");
      //Retrieve the wyrmhole factory for later creation
      var helper = data.wyrmhole;
      setHelper(helper);
    }
    /*Post a message to the extension, telling it to instantiate a a wyrmhole.
    FBDevTeam should be the name of your company inside the plugin configuration. For the echoTestPlugin its FBDevTeam.
    callbackFn is the function that will be called once the result of the postMessage is returned.
    */
    window.postMessage({firebreath: 'ESSPL', callback: callbackFn}, "*");
}

function setHelper(helper) {
    //Using the wyrmholeFactory we create a wyrmhole.
    helper.create(mimetype).then(
        function (wyrmhole) {
          //With the created wyrmhole we instantiate a new FireWyrmJS object that will allow us to create the plugin.
          var FWJS = window.FireWyrmJS;
          //Create pluginFactory that will allow the plugin creation.
          window.pluginFactory = new FWJS(wyrmhole);
        pluginFactory.create(mimetype, {/*some params*/}).then(
          function (pluginObj) {
            //Save the plugin to a gloal var for later access
            plugin = pluginObj;
          },
          function (error) {
            console.log("An Unexpected Error has ocurred: ", error);
          }

          )
        },
        function (error) {
          console.log("An Unexpected Error has ocurred: ", error);
        }
      )
}

function getPluginVersion() {
   if(plugin) {
     plugin.version.then(
         function (data) {
           console.log("Plugin Version Is: ", data);
         },
         function (error) {
           console.log("An Unexpected Error has ocurred: ", error);
         }
       )
   }

   else {
     alert("plugin has not been initialized");
   }
}

function getTestString() {
   if(plugin) {
     plugin.testString.then(
       function (data) {
         console.log("testString current value is: ", data);
       },
       function (error) {
         console.log("An Unexpected Error has ocurred: ", error);
       }
       )
   }

   else {
     alert("plugin has not been initialized");
   }
}

function getTestString2() {

   if(plugin) {
     plugin.getProperty("testString").then(
       function (data) {
         console.log("testString current value is: ", data);
       },
       function (error) {
         console.log("An Unexpected Error has ocurred: ", error);        
       }
       )
   }

   else {
     alert("plugin has not been initialized");
   }
}

function setTestString(testString) {
    if(plugin) {
      plugin.setProperty("testString", testString);
    }

    else {
      alert("plugin has not been initialized");
    }
}

function setTestString2(testString) {
    if(plugin) {
      plugin.testString = testString;
    }
    else {
      alert("plugin has not been initialized");
    }
}

        function pluginLoaded() {
            alert("Plugin loaded!!!");
        }
</script>
</head>
<body onload="initPlugin()">
<!--
    <object id="plugin0" type="application/x-testplugin" width="300" height="300">
    <param name="onload" value="pluginLoaded" />
</object><br />
-->
 <a href="#" onclick="javascript:initPlugin()">Initialize Plugin</a> <br />
<!--<a href="#" onclick="javascript:pluginValid()">Click me!</a> <br />
<a href="#" onclick="javascript:addTestEvent()">Activate click counter</a> <br />
<a href="#" onclick="javascript:testEvent()">Fire a test event</a> <br /> -->
</body>
</html>

Richard Bateman

unread,
Dec 23, 2016, 12:52:48 PM12/23/16
to FireBreath Dev Group
Have you installed the chrome extension?

Richard
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "firebreath-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to firebreath-de...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages