зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1805509 - Add SET_DEFAULT_PDF_HANDLER special message action r=omc-reviewers,emcminn
Differential Revision: https://phabricator.services.mozilla.com/D169818
This commit is contained in:
Родитель
c87b42b8c1
Коммит
41a7e2e406
|
@ -104,6 +104,15 @@ const SpecialMessageActions = {
|
|||
window.getShellService().setAsDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
* Set browser as the default PDF handler.
|
||||
*
|
||||
* @param {Window} window Reference to a window object
|
||||
*/
|
||||
setDefaultPDFHandler(window, onlyIfKnownBrowser = false) {
|
||||
window.getShellService().setAsDefaultPDFHandler(onlyIfKnownBrowser);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset browser homepage and newtab to default with a certain section configuration
|
||||
*
|
||||
|
@ -305,6 +314,12 @@ const SpecialMessageActions = {
|
|||
case "SET_DEFAULT_BROWSER":
|
||||
this.setDefaultBrowser(window);
|
||||
break;
|
||||
case "SET_DEFAULT_PDF_HANDLER":
|
||||
this.setDefaultPDFHandler(
|
||||
window,
|
||||
action.data?.onlyIfKnownBrowser ?? false
|
||||
);
|
||||
break;
|
||||
case "PIN_CURRENT_TAB":
|
||||
let tab = window.gBrowser.selectedTab;
|
||||
window.gBrowser.pinTab(tab);
|
||||
|
|
|
@ -367,6 +367,28 @@
|
|||
"additionalProperties": false,
|
||||
"description": "Message action to set Firefox as default browser"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["SET_DEFAULT_PDF_HANDLER"]
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"onlyIfKnownBrowser": {
|
||||
"type": "boolean",
|
||||
"description": "Only set Firefox as the default PDF handler if the current PDF handler is a known browser."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["type"],
|
||||
"additionalProperties": false,
|
||||
"description": "Message action to set Firefox as the default PDF handler"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -245,10 +245,23 @@ Action for pinning Firefox to the user's taskbar.
|
|||
|
||||
### `SET_DEFAULT_BROWSER`
|
||||
|
||||
Action for configuring the default browser to Firefox on the user's system.
|
||||
Action for setting the default browser to Firefox on the user's system.
|
||||
|
||||
- args: (none)
|
||||
|
||||
### `SET_DEFAULT_PDF_HANDLER`
|
||||
|
||||
Action for setting the default PDF handler to Firefox on the user's system.
|
||||
|
||||
- args:
|
||||
```ts
|
||||
{
|
||||
// Only set Firefox as the default PDF handler if the current PDF handler is a
|
||||
// known browser.
|
||||
onlyIfKnownBrowser?: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
### `SHOW_SPOTLIGHT`
|
||||
|
||||
Action for opening a spotlight tab or window modal using the content passed to the dialog.
|
||||
|
|
|
@ -27,6 +27,7 @@ skip-if = os != "win"
|
|||
[browser_sma_cfrmessageprovider.js]
|
||||
[browser_sma_configure_homepage.js]
|
||||
[browser_sma_default_browser.js]
|
||||
[browser_sma_default_pdf_handler.js]
|
||||
[browser_sma_set_prefs.js]
|
||||
[browser_sma_click_element.js]
|
||||
[browser_sma_handle_multiaction.js]
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_set_default_pdf_handler_no_data() {
|
||||
const sandbox = sinon.createSandbox();
|
||||
const stub = sandbox.stub();
|
||||
|
||||
await SMATestUtils.executeAndValidateAction(
|
||||
{ type: "SET_DEFAULT_PDF_HANDLER" },
|
||||
{
|
||||
ownerGlobal: {
|
||||
getShellService: () => ({
|
||||
setAsDefaultPDFHandler: stub,
|
||||
}),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
stub.callCount,
|
||||
1,
|
||||
"setAsDefaultPDFHandler was called by the action"
|
||||
);
|
||||
Assert.ok(
|
||||
stub.calledWithExactly(false),
|
||||
"setAsDefaultPDFHandler called with onlyIfKnownBrowser = false"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_set_default_pdf_handler_data_false() {
|
||||
const sandbox = sinon.createSandbox();
|
||||
const stub = sandbox.stub();
|
||||
|
||||
await SMATestUtils.executeAndValidateAction(
|
||||
{
|
||||
type: "SET_DEFAULT_PDF_HANDLER",
|
||||
data: {
|
||||
onlyIfKnownBrowser: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
ownerGlobal: {
|
||||
getShellService: () => ({
|
||||
setAsDefaultPDFHandler: stub,
|
||||
}),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
stub.callCount,
|
||||
1,
|
||||
"setAsDefaultPDFHandler was called by the action"
|
||||
);
|
||||
Assert.ok(
|
||||
stub.calledWithExactly(false),
|
||||
"setAsDefaultPDFHandler called with onlyIfKnownBrowser = false"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_set_default_pdf_handler_data_true() {
|
||||
const sandbox = sinon.createSandbox();
|
||||
const stub = sandbox.stub();
|
||||
|
||||
await SMATestUtils.executeAndValidateAction(
|
||||
{
|
||||
type: "SET_DEFAULT_PDF_HANDLER",
|
||||
data: {
|
||||
onlyIfKnownBrowser: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
ownerGlobal: {
|
||||
getShellService: () => ({
|
||||
setAsDefaultPDFHandler: stub,
|
||||
}),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
stub.callCount,
|
||||
1,
|
||||
"setAsDefaultPDFHandler was called by the action"
|
||||
);
|
||||
Assert.ok(
|
||||
stub.calledWithExactly(true),
|
||||
"setAsDefaultPDFHandler called with onlyIfKnownBrowser = true"
|
||||
);
|
||||
});
|
Загрузка…
Ссылка в новой задаче