Bug 1593235 - Hide the "View Background Image" context menu option in the PDF Viewer. r=bdahl

Given that the "View Background Image" option never makes sense in the PDF Viewer, it's simply always removed from the context menu.

Differential Revision: https://phabricator.services.mozilla.com/D52599

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonas Jenwald 2020-02-12 09:40:37 +00:00
Родитель 68b0806130
Коммит 601789bfbc
5 изменённых файлов: 86 добавлений и 2 удалений

Просмотреть файл

@ -854,6 +854,7 @@ class ContextMenuChild extends JSWindowActorChild {
context.hasMultipleBGImages = false;
context.isDesignMode = false;
context.inFrame = false;
context.inPDFViewer = false;
context.inSrcdocFrame = false;
context.inSyntheticDoc = false;
context.inTabBrowser = true;
@ -901,6 +902,10 @@ class ContextMenuChild extends JSWindowActorChild {
context.target.ownerGlobal
);
// Check if we are in the PDF Viewer.
context.inPDFViewer =
context.target.ownerDocument.nodePrincipal.origin == "resource://pdf.js";
// Check if we are in a synthetic document (stand alone image, video, etc.).
context.inSyntheticDoc = context.target.ownerDocument.mozSyntheticDocument;

Просмотреть файл

@ -198,6 +198,7 @@ class nsContextMenu {
this.hasMultipleBGImages = context.hasMultipleBGImages;
this.isDesignMode = context.isDesignMode;
this.inFrame = context.inFrame;
this.inPDFViewer = context.inPDFViewer;
this.inSrcdocFrame = context.inSrcdocFrame;
this.inSyntheticDoc = context.inSyntheticDoc;
this.inTabBrowser = context.inTabBrowser;
@ -578,11 +579,17 @@ class nsContextMenu {
// background images of a stand-alone media document available.
this.showItem(
"context-viewbgimage",
shouldShow && !this.hasMultipleBGImages && !this.inSyntheticDoc
shouldShow &&
!this.hasMultipleBGImages &&
!this.inSyntheticDoc &&
!this.inPDFViewer
);
this.showItem(
"context-sep-viewbgimage",
shouldShow && !this.hasMultipleBGImages && !this.inSyntheticDoc
shouldShow &&
!this.hasMultipleBGImages &&
!this.inSyntheticDoc &&
!this.inPDFViewer
);
document.getElementById("context-viewbgimage").disabled = !this.hasBGImage;

Просмотреть файл

@ -11,6 +11,7 @@ support-files =
../general/head.js
../general/video.ogg
../general/audio.ogg
../../../../extensions/pdfjs/test/file_pdfjs_test.pdf
contextmenu_common.js
[browser_contextmenu_touch.js]

Просмотреть файл

@ -992,6 +992,76 @@ add_task(async function test_image_in_iframe() {
]);
});
add_task(async function test_pdf_viewer_in_iframe() {
await test_contextmenu(
"#test-pdf-viewer-in-frame",
[
"context-navigation",
null,
[
"context-back",
false,
"context-forward",
false,
"context-reload",
true,
"context-bookmarkpage",
true,
],
null,
"---",
null,
"context-savepage",
true,
...(hasPocket ? ["context-pocket", true] : []),
"---",
null,
"context-sendpagetodevice",
true,
[],
null,
"context-selectall",
true,
"frame",
null,
getThisFrameSubMenu([
"context-showonlythisframe",
true,
"context-openframeintab",
true,
"context-openframe",
true,
"---",
null,
"context-reloadframe",
true,
"---",
null,
"context-bookmarkframe",
true,
"context-saveframe",
true,
"---",
null,
"context-printframe",
true,
"---",
null,
"context-viewframeinfo",
true,
]),
null,
"---",
null,
"context-viewsource",
true,
"context-viewinfo",
true,
],
{ maybeScreenshotsPresent: true, shiftkey: true }
);
});
add_task(async function test_textarea() {
// Disabled since this is seeing spell-check-enabled
// instead of spell-add-dictionaries-main

Просмотреть файл

@ -30,6 +30,7 @@ if ("ShadowRoot" in this) {
<iframe id="test-video-in-iframe" src="video.ogg" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-audio-in-iframe" src="audio.ogg" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-image-in-iframe" src="ctxmenu-image.png" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-pdf-viewer-in-frame" src="file_pdfjs_test.pdf" width="100" height="100" style="border: 1px solid black"></iframe>
<textarea id="test-textarea">chssseesbbbie</textarea> <!-- a weird word which generates only one suggestion -->
<div id="test-contenteditable" contenteditable="true">chssseefsbbbie</div> <!-- a more weird word which generates no suggestions -->
<div id="test-contenteditable-spellcheck-false" contenteditable="true" spellcheck="false">test</div> <!-- No Check Spelling menu item -->