Bug 1309033 - Show message in Browser Console when WebExtensions scripts are blocked

smurfd smurfd at gmail.com
Mon Jun 25 23:48:36 UTC 2018


Hi.
>
> I have for some time been looking at :
> https://bugzilla.mozilla.org/show_bug.cgi?id=1309033
>
> I have probably chatted with some of you over IRC at #webextensions 
> about this little here and there, but felt it was easier to have a 
> discussion over Mail could be easier.
>
> My last comment in the bug.
>
> ------------
>
> Short reflection, things has changed since the bug was initially filed and i looked at it a few months ago...
> This :https://searchfox.org/mozilla-central/rev/b7e531410ebc1c7d74a78e86a894e69608db318c/toolkit/components/extensions/WebExtensionPolicy.cpp#400-402
> Has been moved to :https://searchfox.org/mozilla-central/source/toolkit/components/extensions/WebExtensionPolicy.cpp#365
>
> and This message was not shown in the browser console when i looked at it earlier, if i use like the Borderify webextension and go to like addons.mozilla.org...
> "Content Security Policy: The page’s settings blocked the loading of a resource at self (“style-src”)."
>
> At this point i got my funktion running after this :
> https://searchfox.org/mozilla-central/source/toolkit/components/extensions/WebExtensionPolicy.cpp#529-531
> If the boolean for reporing error is True.
>
> Then i would get a output in Browser Console like this:
>
> /This site blocked a WebExtension Script! Site: //https://www.mozilla.org/en-US///Extension: Borderify ExtensionID: 221c5df5-626e-4793-bbd7-69f81aa33c62 /
>
> Im otherwise back to a loop of static/non-static issues getting my function to run in
> https://searchfox.org/mozilla-central/source/toolkit/components/extensions/WebExtensionPolicy.cpp#365
> ---------------
>
>
> When i run my function from :
> https://searchfox.org/mozilla-central/source/toolkit/components/extensions/WebExtensionPolicy.cpp#529-531
> i use like mExtension->LogMessageToBrowserConsole(aURL.URI(), true);
>
> I would obviously prefer to run it from :
> https://searchfox.org/mozilla-central/source/toolkit/components/extensions/WebExtensionPolicy.cpp#365
>
> its declared as non-static to be able to use mHostname and mName to get the Extension Name and ID.
> and i cant find something similar to mExtension within the WebExtensionPolicy::
>
>   nsresult
> WebExtensionPolicy::LogMessageToBrowserConsole(const URLInfo& aURI)
>
> and this is pretty much what it does :
>    URLInfo url(aURI);
>    nsCOMPtr<nsIScriptError> error = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
>    NS_ENSURE_TRUE(error, NS_ERROR_OUT_OF_MEMORY);
>
>    nsCOMPtr<nsIConsoleService> console = do_GetService(
>      NS_CONSOLESERVICE_CONTRACTID);
>    NS_ENSURE_TRUE(console, NS_ERROR_OUT_OF_MEMORY);
>
>    nsPrintfCString msg2("Site: %s\nExtension: %s\nExtensionID: %s\n", ToNewCString(url.Spec()), NS_ConvertUTF16toUTF8(mName.get()).get(), mHostname.get());
>    console->LogStringMessage(NS_LITERAL_STRING("This site blocked a WebExtension Script!").get());
>    console->LogStringMessage(NS_ConvertUTF8toUTF16(msg2.get()).get());
>
>    return NS_OK;
>
> Im very sure it is something very easy that im missing. But im officially stuck. HALP :)
>
> br Nicklas Boman


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/dev-addons/attachments/20180626/bb0265c2/attachment.html>


More information about the Dev-addons mailing list