mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1640318 - Disable only JavaScript in the present tab when using the debugger menu r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D76600
This commit is contained in:
parent
342432ef38
commit
0e4015ecb8
@ -133,3 +133,13 @@ export function ensureHasThread(thread: ActorId) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggleJavaScriptEnabled(enabled: Boolean) {
|
||||||
|
return async ({ panel, dispatch, client }: ThunkArgs) => {
|
||||||
|
await client.toggleJavaScriptEnabled(enabled);
|
||||||
|
dispatch({
|
||||||
|
type: "TOGGLE_JAVASCRIPT_ENABLED",
|
||||||
|
value: enabled,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -38,6 +38,10 @@ export type UIAction =
|
|||||||
+type: "TOGGLE_SOURCE_MAPS_ENABLED",
|
+type: "TOGGLE_SOURCE_MAPS_ENABLED",
|
||||||
+value: boolean,
|
+value: boolean,
|
||||||
|}
|
|}
|
||||||
|
| {|
|
||||||
|
+type: "TOGGLE_JAVASCRIPT_ENABLED",
|
||||||
|
+value: boolean,
|
||||||
|
|}
|
||||||
| {|
|
| {|
|
||||||
+type: "SHOW_SOURCE",
|
+type: "SHOW_SOURCE",
|
||||||
+source: Source,
|
+source: Source,
|
||||||
|
@ -189,6 +189,14 @@ function removeXHRBreakpoint(path: string, method: string) {
|
|||||||
return currentThreadFront().removeXHRBreakpoint(path, method);
|
return currentThreadFront().removeXHRBreakpoint(path, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggleJavaScriptEnabled(enabled: Boolean) {
|
||||||
|
return currentTarget().reconfigure({
|
||||||
|
options: {
|
||||||
|
javascriptEnabled: enabled,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function addWatchpoint(
|
function addWatchpoint(
|
||||||
object: Grip,
|
object: Grip,
|
||||||
property: string,
|
property: string,
|
||||||
@ -579,6 +587,7 @@ const clientCommands = {
|
|||||||
lookupTarget,
|
lookupTarget,
|
||||||
getFrontByID,
|
getFrontByID,
|
||||||
fetchAncestorFramePositions,
|
fetchAncestorFramePositions,
|
||||||
|
toggleJavaScriptEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { setupCommands, clientCommands };
|
export { setupCommands, clientCommands };
|
||||||
|
@ -207,6 +207,7 @@ export type Target = {
|
|||||||
isParentProcess: boolean,
|
isParentProcess: boolean,
|
||||||
isServiceWorker: boolean,
|
isServiceWorker: boolean,
|
||||||
targetForm: Object,
|
targetForm: Object,
|
||||||
|
reconfigure: Object,
|
||||||
|
|
||||||
// Property installed by the debugger itself.
|
// Property installed by the debugger itself.
|
||||||
debuggerServiceWorkerStatus: string,
|
debuggerServiceWorkerStatus: string,
|
||||||
|
@ -9,7 +9,7 @@ import React, { Component } from "react";
|
|||||||
|
|
||||||
import { connect } from "../../utils/connect";
|
import { connect } from "../../utils/connect";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import { features, javascriptPrefs, prefs } from "../../utils/prefs";
|
import { features, prefs } from "../../utils/prefs";
|
||||||
import {
|
import {
|
||||||
getIsWaitingOnBreak,
|
getIsWaitingOnBreak,
|
||||||
getSkipPausing,
|
getSkipPausing,
|
||||||
@ -90,6 +90,7 @@ type Props = {
|
|||||||
isWaitingOnBreak: boolean,
|
isWaitingOnBreak: boolean,
|
||||||
horizontal: boolean,
|
horizontal: boolean,
|
||||||
skipPausing: boolean,
|
skipPausing: boolean,
|
||||||
|
javascriptEnabled: boolean,
|
||||||
topFrameSelected: boolean,
|
topFrameSelected: boolean,
|
||||||
resume: typeof actions.resume,
|
resume: typeof actions.resume,
|
||||||
stepIn: typeof actions.stepIn,
|
stepIn: typeof actions.stepIn,
|
||||||
@ -100,6 +101,7 @@ type Props = {
|
|||||||
toggleSkipPausing: typeof actions.toggleSkipPausing,
|
toggleSkipPausing: typeof actions.toggleSkipPausing,
|
||||||
toggleInlinePreview: typeof actions.toggleInlinePreview,
|
toggleInlinePreview: typeof actions.toggleInlinePreview,
|
||||||
toggleSourceMapsEnabled: typeof actions.toggleSourceMapsEnabled,
|
toggleSourceMapsEnabled: typeof actions.toggleSourceMapsEnabled,
|
||||||
|
toggleJavaScriptEnabled: typeof actions.toggleJavaScriptEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CommandBar extends Component<Props> {
|
class CommandBar extends Component<Props> {
|
||||||
@ -258,11 +260,11 @@ class CommandBar extends Component<Props> {
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
key="debugger-settings-menu-item-disable-javascript"
|
key="debugger-settings-menu-item-disable-javascript"
|
||||||
className="menu-item debugger-settings-menu-item-disable-javascript"
|
className="menu-item debugger-settings-menu-item-disable-javascript"
|
||||||
checked={!javascriptPrefs.enableJavaScript}
|
checked={!this.props.javascriptEnabled}
|
||||||
label={L10N.getStr("settings.disableJavaScript.label")}
|
label={L10N.getStr("settings.disableJavaScript.label")}
|
||||||
tooltip={L10N.getStr("settings.disableJavaScript.tooltip")}
|
tooltip={L10N.getStr("settings.disableJavaScript.tooltip")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
javascriptPrefs.enableJavaScript = !javascriptPrefs.enableJavaScript;
|
this.props.toggleJavaScriptEnabled(!this.props.javascriptEnabled);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@ -314,6 +316,7 @@ const mapStateToProps = state => ({
|
|||||||
isWaitingOnBreak: getIsWaitingOnBreak(state, getCurrentThread(state)),
|
isWaitingOnBreak: getIsWaitingOnBreak(state, getCurrentThread(state)),
|
||||||
skipPausing: getSkipPausing(state),
|
skipPausing: getSkipPausing(state),
|
||||||
topFrameSelected: isTopFrameSelected(state, getCurrentThread(state)),
|
topFrameSelected: isTopFrameSelected(state, getCurrentThread(state)),
|
||||||
|
javascriptEnabled: state.ui.javascriptEnabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect<Props, OwnProps, _, _, _, _>(mapStateToProps, {
|
export default connect<Props, OwnProps, _, _, _, _>(mapStateToProps, {
|
||||||
@ -326,4 +329,5 @@ export default connect<Props, OwnProps, _, _, _, _>(mapStateToProps, {
|
|||||||
toggleSkipPausing: actions.toggleSkipPausing,
|
toggleSkipPausing: actions.toggleSkipPausing,
|
||||||
toggleInlinePreview: actions.toggleInlinePreview,
|
toggleInlinePreview: actions.toggleInlinePreview,
|
||||||
toggleSourceMapsEnabled: actions.toggleSourceMapsEnabled,
|
toggleSourceMapsEnabled: actions.toggleSourceMapsEnabled,
|
||||||
|
toggleJavaScriptEnabled: actions.toggleJavaScriptEnabled,
|
||||||
})(CommandBar);
|
})(CommandBar);
|
||||||
|
@ -41,6 +41,7 @@ export type UIState = {
|
|||||||
isLogPoint: boolean,
|
isLogPoint: boolean,
|
||||||
inlinePreviewEnabled: boolean,
|
inlinePreviewEnabled: boolean,
|
||||||
sourceMapsEnabled: boolean,
|
sourceMapsEnabled: boolean,
|
||||||
|
javascriptEnabled: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createUIState = (): UIState => ({
|
export const createUIState = (): UIState => ({
|
||||||
@ -58,6 +59,7 @@ export const createUIState = (): UIState => ({
|
|||||||
cursorPosition: null,
|
cursorPosition: null,
|
||||||
inlinePreviewEnabled: features.inlinePreview,
|
inlinePreviewEnabled: features.inlinePreview,
|
||||||
sourceMapsEnabled: prefs.clientSourceMapsEnabled,
|
sourceMapsEnabled: prefs.clientSourceMapsEnabled,
|
||||||
|
javascriptEnabled: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
function update(state: UIState = createUIState(), action: Action): UIState {
|
function update(state: UIState = createUIState(), action: Action): UIState {
|
||||||
@ -76,6 +78,10 @@ function update(state: UIState = createUIState(), action: Action): UIState {
|
|||||||
return { ...state, inlinePreviewEnabled: action.value };
|
return { ...state, inlinePreviewEnabled: action.value };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "TOGGLE_JAVASCRIPT_ENABLED": {
|
||||||
|
return { ...state, javascriptEnabled: action.value };
|
||||||
|
}
|
||||||
|
|
||||||
case "TOGGLE_SOURCE_MAPS_ENABLED": {
|
case "TOGGLE_SOURCE_MAPS_ENABLED": {
|
||||||
prefs.clientSourceMapsEnabled = action.value;
|
prefs.clientSourceMapsEnabled = action.value;
|
||||||
return { ...state, sourceMapsEnabled: action.value };
|
return { ...state, sourceMapsEnabled: action.value };
|
||||||
|
@ -77,7 +77,6 @@ if (isDevelopment()) {
|
|||||||
pref("devtools.debugger.features.watchpoints", true);
|
pref("devtools.debugger.features.watchpoints", true);
|
||||||
pref("devtools.debugger.features.frame-step", true);
|
pref("devtools.debugger.features.frame-step", true);
|
||||||
pref("devtools.editor.tabsize", 2);
|
pref("devtools.editor.tabsize", 2);
|
||||||
pref("javascript.enabled", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const prefs = new PrefsHelper("devtools", {
|
export const prefs = new PrefsHelper("devtools", {
|
||||||
@ -122,10 +121,6 @@ export const prefs = new PrefsHelper("devtools", {
|
|||||||
indentSize: ["Int", "editor.tabsize"],
|
indentSize: ["Int", "editor.tabsize"],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const javascriptPrefs = new PrefsHelper("javascript", {
|
|
||||||
enableJavaScript: ["Bool", "enabled"],
|
|
||||||
});
|
|
||||||
|
|
||||||
// The pref may not be defined. Defaulting to null isn't viable (cursor never blinks).
|
// The pref may not be defined. Defaulting to null isn't viable (cursor never blinks).
|
||||||
// Can't use CodeMirror.defaults here because it's loaded later.
|
// Can't use CodeMirror.defaults here because it's loaded later.
|
||||||
// Hardcode the fallback value to that of CodeMirror.defaults.cursorBlinkRate.
|
// Hardcode the fallback value to that of CodeMirror.defaults.cursorBlinkRate.
|
||||||
|
@ -11,7 +11,6 @@ async function toggleJavaScript(dbg, shouldBeCheckedAtStart) {
|
|||||||
menuButton.click();
|
menuButton.click();
|
||||||
await waitForTime(200);
|
await waitForTime(200);
|
||||||
|
|
||||||
// Wait for the menu to show before trying to click the item
|
|
||||||
const { parent } = dbg.panel.panelWin;
|
const { parent } = dbg.panel.panelWin;
|
||||||
const { document } = parent;
|
const { document } = parent;
|
||||||
|
|
||||||
@ -34,10 +33,8 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Clicking the disable javascript button in the settings menu");
|
info("Clicking the disable javascript button in the settings menu");
|
||||||
await toggleJavaScript(dbg, false);
|
await toggleJavaScript(dbg, false);
|
||||||
is(Services.prefs.getBoolPref("javascript.enabled"), false, "JavaScript is disabled");
|
|
||||||
|
|
||||||
info("Reloading page to ensure there are no sources");
|
info("Waiting for reload triggered by disabling javascript");
|
||||||
await reload(dbg);
|
|
||||||
await waitForSourceCount(dbg, 0);
|
await waitForSourceCount(dbg, 0);
|
||||||
|
|
||||||
info("Clicking the disable javascript button in the settings menu to reenable JavaScript");
|
info("Clicking the disable javascript button in the settings menu to reenable JavaScript");
|
||||||
|
@ -585,7 +585,6 @@ async function clearDebuggerPreferences(prefs = []) {
|
|||||||
Services.prefs.clearUserPref("devtools.debugger.scopes-visible");
|
Services.prefs.clearUserPref("devtools.debugger.scopes-visible");
|
||||||
Services.prefs.clearUserPref("devtools.debugger.skip-pausing");
|
Services.prefs.clearUserPref("devtools.debugger.skip-pausing");
|
||||||
Services.prefs.clearUserPref("devtools.debugger.map-scopes-enabled");
|
Services.prefs.clearUserPref("devtools.debugger.map-scopes-enabled");
|
||||||
Services.prefs.clearUserPref("javascript.enabled");
|
|
||||||
await pushPref("devtools.debugger.log-actions", true);
|
await pushPref("devtools.debugger.log-actions", true);
|
||||||
|
|
||||||
for (const pref of prefs) {
|
for (const pref of prefs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user