Commit a79d0645 authored by ariasuni's avatar ariasuni
Browse files

Disable duplicate and discard context menu items when they can’t work

- Disable duplicate for URL with the resource: scheme
- Disable discard for about: URL (except about:blank/newtab)
parent f99a8f25
Pipeline #301185 passed with stages
in 2 minutes and 3 seconds
......@@ -2,7 +2,7 @@
import Sidetab from "./sidetab.js";
const IS_PRIVILEGED_PAGE_URL = /^(about|chrome|data|file|javascript):*/;
const HAS_PRIVILEGED_SCHEME = /^(about|chrome|data|file|javascript|resource):*/;
export default class ContextMenu {
constructor(sidebar, tablist) {
......@@ -225,15 +225,16 @@ export default class ContextMenu {
}
static canUnload(tab) {
// Trying to discard an about: tab fails silently
// https://bugzilla.mozilla.org/show_bug.cgi?id=1631157
return (
!tab.active &&
!tab.discarded &&
!tab.url.startsWith("about:") &&
!tab.url.startsWith("chrome:")
tab.url === "about:blank" ||
tab.url === "about:newtab" ||
(!tab.active && !tab.discarded && !tab.url.startsWith("about:"))
);
}
static canOpen(url) {
return !IS_PRIVILEGED_PAGE_URL.test(url) || url === "about:newtab" || url === "about:blank";
return url === "about:blank" || url === "about:newtab" || !HAS_PRIVILEGED_SCHEME.test(url);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment