javascriptfirefoxfirefox-addonfirefox-addon-sdk

addons.mozilla.org validation shows compile-time error in the JavaScript


Note:addons works correctly but getting error in firefox validation addon website https://addons.mozilla.org/en-us/developers/addon/validate

my code

panel.port.on("changing_now_speed_val", function (speed) {

    var com = 'document.getElementsByTagName("video")[0].playbackRate='+speed + ';';
    tabs.activeTab.attach({
        contentScript: com
    });
});

Error while testing on it says

https://addons.mozilla.org/en-us/developers/addon/validate

Extension Tests

JavaScript Compile-Time Error

Warning: A compile-time error in the JavaScript halted validation of that file.

Message: expected expression, got ';
resources/html5_youtube_video_speed_controller/lib/main.js

warning pic

But addons works correctly


Solution

  • https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/Loading_Content_Scripts

    "Unless your content script is extremely simple and consists only of a static string, don't use contentScript: if you do, you may have problems getting your add-on approved on AMO.

    Instead, keep the script in a separate file and load it using contentScriptFile. This makes your code easier to maintain, secure, debug and review"

    There is more info there:

    https://bugzilla.mozilla.org/show_bug.cgi?id=1185355