Search code examples
google-chrome-extensiongoogle-nativeclient

NaCl is supposed to be enabled by default in unpacked extensions, yet I can't use it from one


"NaCl is currently only turned on by default for applications/extensions from the Chrome Webstore, or unpacked extensions for development purposes." - the Internet

Yet I can't seem to be able to use NaCl from an unpacked extension. (I did not try the Web Store.)

I have a really simple test extension which has the following in its background.js:

function clicked() {
    var testNaclElement = document.createElement("embed");
    testNaclElement.setAttribute("type","application/x-nacl");
    testNaclElement.setAttribute("width",0);
    testNaclElement.setAttribute("height",0);
    document.body.appendChild(testNaclElement);
    alert(testNaclElement.postMessage?true:false);
    document.body.removeChild(testNaclElement);
}

chrome.browserAction.onClicked.addListener(updateIcon);
updateIcon();

This extension reports true when the NaCl is enabled in chrome://flags, but when NaCl is disabled in chrome://flags (which is the default) it reports false.

I expected it to report true.

What am I missing?

Update:

It seems that inventing my own detection code not such a good idea after all. If I create and install an unpacked chrome webapp that points to url X, then NaCl will work on that page, but this detection code will still report false, while the very same code reports true when on a normal webpage with NaCl enabled in chrome://flags.

BUT if create an extension (not a chrome webapp) that uses NaCl in an iFrame which points to url X, then NaCl will not work in it.

BUT if I create a webapp that points to url X and an extension that uses url X in an iFrame, then both will work if installed at the same time.

Update2: If I actually include the nmf and nexe in the extension, then it works.

Update3: nexe needn't be included in the extension.


Solution

  • Chrome requires nmf location to belong to extension. Empty nmf attribute doesn't have this property.