Skip to content

Fix 'prevent-element-src-loading' — TrustedScriptURL is not defined in Firefox #514

@AdamWr

Description

@AdamWr

TrustedScriptURL is not defined in Firefox and scriptlet does not work correctly.

Steps to reproduce:

  1. Add to user rules:
example.org#%#//scriptlet('prevent-element-src-loading', 'script', 'test.js')
  1. Go to - https://example.org/
  2. Open devtools and run in console:
(() => {
    const script = document.createElement('script');
    script.src = 'test.js';
    document.body.appendChild(script);
})();

There is an error: Uncaught ReferenceError: TrustedScriptURL is not defined.

Screenshot Image

The problem seems to be here:

if (policy && urlValue instanceof TrustedScriptURL) {

TrustedScriptURL is undefined and urlValue instanceof TrustedScriptURL throws error.
I guess we can change it to:

if (policy && policy.isSupported && urlValue instanceof TrustedScriptURL) { 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions