---
schema_version: "1"
id: 98a30c35cb9b65ce72b3e09fbfff6e6462ae43ee215afbbbad5fb16b887f1ec1
title: Debug with Distortions Disabled
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwc/lightning-components-security/guides/lws/lws-debug-distortion-flags.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-components-security/guide/lws-debug-distortion-flags.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1dffa11dad31d1e4e80ee13a24810dd2f1ef5d31f745319a74c61bf61dcd9302
products:
  - Security for Lightning Components
  - lwc
---
# Debug with Distortions Disabled

To switch Lightning Web Security (LWS) [distortions](https://developer.salesforce.com/docs/platform/lightning-components-security/guide/lws-architecture.md#distortions) off and on for certain APIs while you debug, use commands in your browser’s developer console. It can be helpful to observe how your component’s behavior changes when you disable distortions on a particular API and then enable them again.

Before you can disable distortions, you must [enable debug mode](/docs/platform/lwc/guide/debug-mode-enable.html) for your username in the org. Then you can set flags in the browser’s developer console to disable and enable distortions on APIs.

**tip:** We recommend using Chrome and [Chrome DevTools](https://developer.chrome.com/docs/devtools). See [Debug Using Chrome DevTools](/docs/platform/lwc/guide/debug-dev-tools.html) in the _Lightning Web Components Developer Guide_.

## Workflow to Debug with Distortion Flags

The distortion flags are most useful if you set them when the execution is paused, such as when you hit a breakpoint. We recommend using this workflow:

1. Identify a point in your code that you want to debug and set a breakpoint.
2. Refresh the browser page and walk through the steps needed to reach that breakpoint.
3. When execution pauses at the breakpoint, go to the console and [disable distortions](#disable-and-enable-distortions-while-debugging) that you suspect are affecting your code.
4. Allow the code execution to continue and observe if the behavior of your code changes with the distortions disabled.

## Disable and Enable Distortions While Debugging

To disable and enable distortions for a given API, use `$LWS.namespaces` commands in the browser’s developer console to set the values of corresponding distortion flags.

You can work with multiple namespaces that are present in your org. The commands target distortions in the namespace you specify.

The command syntax is:

`$LWS.namespaces.`_ns_`.distortions.`_flag_

where _ns_ represents the namespace and _flag_ represents a distortion flag name.

### List the Distortion Flags

To list the distortion flags in the `c` default namespace, enter this command in the browser’s developer console and press Enter.

```
$LWS.namespaces.c.distortions
```

The list of distortion flags is collapsed initially. Click the expander icon to reveal the distortion flag names.

![List of distortion flags in c](https://developer.salesforce.com/media/debug_lws_distortion_flags.png)

See [LWS Distortion Flags for Debug Sessions](#lws-distortion-flags-for-debug-sessions) for descriptions of the distortion flags.

**note:** Don’t use these deprecated flags. Disabling the distortions associated with these flags can cause your code to break in the debugger.

- `dataset`
- `history`
- `indexedDB`
- `notification`
- `performance`
- `postMessage`
- `style`

### Disable a Distortion

To disable distortions for an API using one of the listed distortion flags, set the flag to `false`. For example, to disable distortions for the `XMLHttpRequest` API, type this command and press **Enter**.

```
$LWS.namespaces.c.distortions.xhr = false
```

In the developer tools’ Sources view, use the debugger panel to observe the component running with the specified LWS distortions disabled.

### Enable a Distortion

To enable the distortion again in the current session, set the property to `true`.

```
$LWS.namespaces.c.distortions.xhr = true
```

**tip:** When you reload the page all the properties reset to `true`.

### List the Namespaces in Your Org

You can view which namespaces support disabling and enabling distortion flags in your org. The command reveals only custom namespaces. You can’t see the namespaces that Salesforce owns, for example.

Enter this command in the console:

```
$LWS.namespaces
```

The console displays a list of available namespaces. If you’re only using the default namespace, you see the `c` namespace.

![List of c namespace](https://developer.salesforce.com/media/debug_lws_distortion_flags_namespaces.png)

To see the distortion flags for a namespace, click the expander icon by the namespace.

In this example, the command shows the namespaces `external` and `untrusted` in a test org.

![List of other namespaces](https://developer.salesforce.com/media/debug_lws_distortion_flags_external_namespace.png)

All namespaces support the same flags. You can set the values separately in different namespaces, whichever is appropriate for the component you’re debugging.

You can also enter a command to display the distortion flags of a namespace. This example uses the command to display distortion properties in the `external` namespace.

```
$LWS.namespaces.external.distortions
```

### Check the Value of a Distortion Flag

To check the current value of a distortion flag, enter a command specifying the flag name.

For example, use this command to determine if all `XMLHttpRequest` distortions are enabled in the `c` namespace.

```
$LWS.namespaces.c.distortions.xhr
```

The flags are all set to `true` by default.

![Command shows the value of the xhr flag set to true](https://developer.salesforce.com/media/debug_lws_distortion_flag_value.png)

To disable all `XMLHttpRequest` distortions in the debugging session, set the `xhr` flag to `false`.

![Command shows the value of the xhr flag set to false](https://developer.salesforce.com/media/debug_lws_distortion_flag_false.png)

Setting `xhr` to `false` turns off all of the security-based API distortions for `XMLHttpRequest`.

## LWS Distortion Flags for Debug Sessions

Here’s a list of the distortion flags and the corresponding distortions that are disabled when you set the flag to `false`.

| Flag                       | What it controls                                                                                                                                                                                                                                                                                                        |
| :------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attributes`               | All distortions related to `getAttribute`, `setAttribute`, `hasAttribute`, `toggleAttribute` for attributes described in [LWS Distortion Viewer](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer)                                                                                   |
| `caches`                   | All [`CacheStorage`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#CacheStorage_delete-value) API distortions                                                                                                                                                                     |
| `cookieStore`              | All [`CookieStore`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#CookieStore_addEventListener-value) API distortions                                                                                                                                                             |
| `customElements`           | [`CustomElementRegistry`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#CustomElementRegistry_define-value) distortions                                                                                                                                                           |
| `dataset`                  | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `documentCookie`           | [`Document.prototype.cookie` getter and setter](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Document_cookie-setter) distortions                                                                                                                                                 |
| `documentDomain`           | [`Document.prototype.domain` setter](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Document_domain-setter) distortion                                                                                                                                                             |
| `documentExecCommand`      | [`Document.prototype.execCommand`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Document_execCommand-value) distortion                                                                                                                                                           |
| `domParserParseFromString` | [`DOMParser.prototype.parseFromString`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#DOMParser_parseFromString-value) distortion                                                                                                                                                 |
| `element`                  | All [`Element.prototype`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Element_after-value) distortions except the `Element.prototype.innerHTML` setter, which is controlled with the `innerHTML` flag                                                                           |
| `history`                  | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `indexdDB`                 | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `innerHTML`                | [`Element.prototype.getInnerHTML`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Element_getInnerHTML-value) and [`Element.prototype.innerHTML` setter](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Element_innerHTML-setter) distortions |
| `navigatorSendBeacon`      | [`Navigator.sendBeacon`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Navigator_sendBeacon-value) distortion                                                                                                                                                                     |
| `node`                     | All [`Node.prototype`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Node_appendChild-value) API distortions                                                                                                                                                                      |
| `notification`             | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `performance`              | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `postMessage`              | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `range`                    | All [`Range.prototype`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Range_createContextualFragment-value) API distortions                                                                                                                                                       |
| `script`                   | [`SVGScriptElement.prototype.href` setter](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#SVGScriptElement_href-setter) distortion                                                                                                                                                 |
| `selection`                | [`Selection.prototype`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Selection_collapse-value) API distortions                                                                                                                                                                   |
| `setInterval`              | [`Window.setInterval`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Window_setInterval-value) API distortion                                                                                                                                                                     |
| `setTimeout`               | [`Window.setTimeout`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Window_setTimeout-value) API distortion                                                                                                                                                                       |
| `storage`                  | All [`Storage.prototype`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Storage_clear-value) API distortions                                                                                                                                                                      |
| `style`                    | This flag is deprecated. Don’t use it.                                                                                                                                                                                                                                                                                  |
| `windowFetch`              | [`Window.fetch`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Window_fetch-value) distortion                                                                                                                                                                                     |
| `windowFrames`             | [`Window.frames` getter](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#Window_frames-getter) distortion                                                                                                                                                                           |
| `xhr`                      | All [`XMLHttpRequest.prototype`](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer#XMLHttpRequest_open-value) distortions                                                                                                                                                             |

**See Also**

- [LWS Distortion Viewer](https://developer.salesforce.com/docs/component-library/tools/lws-distortion-viewer)
- [Debug with Lightning Web Security Enabled
  ](lws-debug.md)
- [Limitations for Debugging with Lightning Web Security Enabled](https://developer.salesforce.com/docs/platform/lightning-components-security/guide/lws-debug-limitations.md)
- [_Lightning Web Components Developer Guide_: Debug Lightning Web Components](/docs/platform/lwc/guide/debug-intro.html)
- [_Lightning Web Components Developer Guide_: Debug Using Chrome DevTools](/docs/platform/lwc/guide/debug-dev-tools.html)
