Skip to content Skip to sidebar Skip to footer

Module Load Progress Events In Nacl With Manifest_version = 2 And No Inline Javascript

I upgraded my manifest_version to '2' as per this document, and then was suprised to see chrome burping up errors like: Refused to execute inline script because it violates the fo

Solution 1:

According to the documentation for NaCl progress events, event listeners have to be added as follows:

<divid="listener"><scripttype="text/javascript">document.getElementById('listener').addEventListener('load', function() {
        // Example
    }, true);
  </script><embedname="nacl_module"...type="application/x-nacl" /></div>

This if forbidden by the Content security policy (see also). There's only one way to solve it: By moving the script to an external file:

<div id="listener">
  <scriptsrc="listener-load.js"></script><embedname="nacl_module"...type="application/x-nacl" />
</div>

// listener-load.js:document.getElementById('listener').addEventListener('load', ..., true);

Because the construction of the DOM blocks until the external file is loaded, the script is loaded before the <embed> tag is inserted. Since the external files are packaged with the extension, the impact on performance can be neglected.

Post a Comment for "Module Load Progress Events In Nacl With Manifest_version = 2 And No Inline Javascript"