var ab = document.getElementById("alert_button");
ab.addEventListener("click", clickAlertButton);
function clickAlertButton() {
alert("This is alert message");
}
And I test extension on two versions Mosilla:
Firefox 55.0.2 for Linux -
In Firefox, the sidebar and the page content are in different context & scope.
That is a security measure so the two cant interact directly as they have different privileges. Sidebar has far more privileges than the page content.
That should be the same across all platforms and if it isn’t yet, it will be.
That means the alert() from sidebar belongs to sidebar and should show in sidebar (ugly but correct).
On Linux you are using Firefox 55 which is pre-Quantum so not all new security measures have been applied as it is still a legacy version.
On Windows you are using Firefox 59 which is post-Quantum.
Sure…
You would need to get the active Tab first using tabs.query() and then inject the alert() in the page content using tabs.executeScript().
Personally, I often use the notification API instead of modal alert(). There is a plan (both Firefox & Chrome) to remove modal pop-ups (alert/confirm/prompt) in future.
Is notification API modal window too? Is it prevents the user from accessing the rest of the program’s interface until the dialog box is closed?
I will try to understand
The WebExtension notifications.create() isn’t modal.
Please also note the Firefox prevents tabs.executeScript() on some pages (like addons.mozilla.org or about:* etc).
Chrome also has some restriction on some of its pages.