Evaluate JavaScript Code Compatibility with Lightning Locker

Ensure that your code is compatible with Lightning Locker by running the code with Locker enabled. Run the code a second time with Locker disabled to see if any errors are due to Lightning Locker restrictions.

Let's look at an example that uses a prohibited DOM API.

  1. Paste this code into the console.

  2. Click Evaluate.

    Note the error in the LOCKER ON column of the results window.

    You get this error because AbortController is an experimental interface in the DOM API and is not allowed by Lightning Locker.

    The LOCKER OFF column shows N/A as this column isn't relevant when the Locker toggle is enabled.

  3. Click the Locker toggle to disable Lightning Locker.

  4. Click Evaluate to rerun the code sample with Lightning Locker disabled.

    The second row of the results window shows there's no longer an error when Lightning Locker is disabled. The LOCKER OFF column shows [object AbortController], which is the return value of the sample code.

    Locker Console Example with prohibited DOM API.

Use the Locker API Viewer to see the DOM APIs exposed by Lightning Locker versus the standard DOM APIs for the most complex wrappers: SecureDocument, SecureElement, and SecureWindow.

See Also