elbywan / yett

🔐A small webpage library to control the execution of (third party) scripts

Home Page:https://elbywan.github.io/yett/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yett lib is throwing errors when trying to test it using WASP plugin

rohitreddy0109 opened this issue · comments

Team,

I am using WASP which is a chrome extension which will give a visual representation of all the tags and scripts loaded into DOM. When I try to test yett library using WASP plugin it throws js errors on the page load after clicking on "WASP" in chrome dev tools. I have tested it using yett demo app and with my custom app as well and its the same issue. Below is the error:

monkey.js:16 Uncaught TypeError: Cannot redefine property: src at Function.defineProperties (<anonymous>) at HTMLDocument.document.createElement (monkey.js:16) at (index):21 at (index):25

Attached are the screen shots of the same
yett_console_error
yett_script_error

Can someone please provide an update on the above issue ?

Hi @rohitreddy0109,

When I try to test yett library using WASP plugin it throws js errors on the page load after clicking on "WASP" in chrome dev tools.

I tried browsing the demo website with the extension enabled, but did not get any errors.

Capture d’écran 2019-11-08 à 08 40 21

We try to keep yett as compatible as possible, but in this case WASP seems to be closed source so there's not way to exactly know how they are tampering with the script tags in the page, especially if I cannot reproduce the issue.

Could you try to fix it on your side and make a PR?

Hi @rohitreddy0109,

When I try to test yett library using WASP plugin it throws js errors on the page load after clicking on "WASP" in chrome dev tools.

I tried browsing the demo website with the extension enabled, but did not get any errors.

Capture d’écran 2019-11-08 à 08 40 21

We try to keep yett as compatible as possible, but in this case WASP seems to be closed source so there's not way to exactly know how they are tampering with the script tags in the page, especially if I cannot reproduce the issue.

Could you try to fix it on your side and make a PR?

Hi @elbywan,
I am able to reproduce the issue. Once you load the WASP plugin, please try to refresh the page again and/or click on try again button, then you will see the console errors in dev tools.

The issue is WASP plugin is trying to create a "script" element using object.defineProperty with default value as "false" for "configurable" in 'src' property of the object and yett lib is again trying to create the "script" element using the object.defineProperties and then its throwing an error saying "cannot redefine property src' since the configurable is false.

One way to fix this is not to create the "script" element again with src property if its already present in the DOM. I have tested within my app with this fix and it works fine and I can quickly raise a PR for this fix ?

Attached is the screen shot of the script of the wasp plugin, which is creating this script.
WASP plugin error

@rohitreddy0109 Sorry for the delay,

The issue is WASP plugin is trying to create a "script" element using object.defineProperty with default value as "false" for "configurable" in 'src' property of the object and yett lib is again trying to create the "script" element using the object.defineProperties and then its throwing an error saying "cannot redefine property src' since the configurable is false.

I think that the issue is more likely to be caused because this plugin monkey patches the document.createElement. When some code tries to programmatically create a script tag, the plugin locks down the src element before yett's monkey patched function is called and this causes a crash.

This means that yett and WASP will never be compatible, and that no script tag could be created.

But I released a new version that should at least not prevent script creation, but instead displays a warning in the console.

I also added a small warning paragraph in the readme.