New issue
Advanced search Search tips

Issue 677769 link

Starred by 1 user

Issue metadata

Status: Archived
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Chrome extension that uses setAttribute('onclick',...) is additive instead of replacing previous setAttribute value

Reported by m...@gooddiehl.net, Jan 2 2017

Issue description

In an extension (this doesn't seem to be an issue for a regular script in a webpage) when using setAttribute:
   setAttribute('onclick', "window.open('https://www.google.com')")

If the setAttribute() is called multiple times on the same div, it doesn't replace the previous value, but adds to it. Even though DOM only shows a single 'onclick' attribute, there are actually multiple values hidden in there.

Note this issue was discovered since my extension adds helpful links to Amazon. I've worked around it by changing to use addEventListener('click') instead of setAttribute('onclick'). Link to full extension, if curious: https://chrome.google.com/webstore/detail/historic-price-shopper-am/epopkendmjlkmkmcdmbmfnnndfbfdhbc

Chrome Version       :  55.0.2883.87 m
URLs (if applicable) : 
Other browsers tested: N/A, Chrome extension bug

What steps will reproduce the problem?
(1) Create an empty directory (for extension code)
(2) Download the manifest.json and amazon.user.js code (attached) into this directory
(3) Enable Developer mode in Extensions settings, and load unpacked extension, pointing to the folder created in step 1
(4) Navigate to https://www.amazon.com/dp/B00FSKX266, and you will see "Click Me!" near top right of page, close to Add to Cart button
(5) If you click on the link, instead of one new tab being created, multiple tabs will be created

What is the expected result?
Only one new tab should have been created, navigating to www.google.com

What happens instead?
Up to 5 new tabs are created.

Please provide any additional information below. Attach a screenshot if
possible.

 
manifest.json
278 bytes View Download
amazon.user.js
1.2 KB View Download

Comment 1 by ajha@chromium.org, Jan 4 2017

Components: Platform>Extensions
Labels: Needs-Triage-M55

Comment 2 by m...@gooddiehl.net, Jan 4 2017

Another user noted that using this extension, he did not get multiple tabs, but only one. And that one tab only had the first 'onclick' attribute, instead of the updated 'onclick' attributes. The user put the same code into a Firefox extension, and it worked as expected. That user had the same version of Chrome as me.
Cc: kkaluri@chromium.org
Labels: Needs-Feedback
Unable to reproduce the issue on Windows 10 with chrome version #55.0.2883.87

These are the steps i followed 
1. Loaded the extension from the given files in comment #0
2. Navigated to following url "https://www.amazon.com/dp/B00FSKX266?th=1"
3. Clicked on the "Click me"

Observed that it has opened only one tab which is navigated to google.co.in and searched for "undefined"
Attaching the screencast for your reference.
matt@ could you please look into the attached screencast and let us know your observations.

Thank You...
Issue 677769.mp4
1.6 MB View Download

Comment 4 by m...@gooddiehl.net, Jan 11 2017

Hi, That is the same result as my Comment2. Note that it seems to still be a bug, although not exactly how I reported it.

Expected: It should open a new tab which is navigated to google.com and searched for "4"

Actual (that you observed): It opened tab and only the first setAttribute() took affect (first time it is passed null or "undefined"). So it navigated to google.com and searched for "undefined".
Project Member

Comment 5 by sheriffbot@chromium.org, Jan 18 2017

Labels: -Needs-Feedback Needs-Review
Owner: kkaluri@chromium.org
Thank you for providing more feedback. Adding requester "kkaluri@chromium.org" for another review and adding "Needs-Review" label for tracking.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 6 by cda...@chromium.org, Mar 13 2017

Cleaning up "Needs-Review" label as we are not using this label for triage. Ref  bug 684919 

Comment 7 by cda...@chromium.org, Mar 13 2017

Labels: -Needs-Review
Project Member

Comment 8 by sheriffbot@chromium.org, Mar 15 2018

Status: Archived (was: Unconfirmed)
Issue has not been modified or commented on in the last 365 days, please re-open or file a new bug if this is still an issue.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment