Newer Version Available
Evaluate JavaScript Code Compatibility with Locker Service
Let's look at an example that uses a prohibited DOM API.
- Paste this code into the
console.
1var controller = new AbortController(); 2controller; - Click Evaluate.
Note the error in the LOCKER ON column of the results window.
1TypeError: AbortController is not a constructorYou get this error because AbortController is an experimental interface in the DOM API and is not allowed by Locker Service.
The LOCKER OFF column shows – (dash) as this column isn't relevant when the Locker toggle is enabled.
- Click the Locker toggle to disable Locker Service.
- Click Evaluate to rerun the code sample with Locker Service
disabled.
The second row of the results window shows there's no longer an error when Locker Service is disabled. The LOCKER OFF column shows [object AbortController], which is the return value of the sample code.
Use the Locker Service API Viewer to see the DOM APIs exposed by Locker Service versus the standard DOM APIs for the most complex wrappers: SecureDocument, SecureElement, and SecureWindow.