New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 614593 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 3
Type: Bug



Sign in to add a comment

event handler depend on attribute of element break by translation

Reported by shie...@kkvesper.jp, May 25 2016

Issue description

Chrome Version       : 50.0.2661.102 (Official Build) m (64-bit)
URLs (if applicable) : https://www.tablesolution.com/
Other browsers tested: n/a

What steps will reproduce the problem?
(1) Visit https://www.tablesolution.com/ The page text is in Japanese
(2) In Chrome menu, choose "Translate this page" to English
(3) Click on the "YES" or "NO" links at top.

What is the expected result?
Click "YES", you should navigate to https://www.tablesolution.com/en
Click "NO", nothing should happen (javascript: void(0) set on link).

What happens instead?
For both YES and NO, browser navigates to https://www.tablesolution.com/undefined


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

 
Cc: tkonch...@chromium.org
Components: UI>Browser>Translate
Labels: M-53
Status: Untriaged (was: Unconfirmed)
Able to reproduce the issue on win8.1, mac and linux and observed that clicking "YES" or "NO" navigates to https://www.tablesolution.com/undefined after translating the page to English.

This can be seen from M30 builds to latest canary

Confirming the issue for more inputs on this
Labels: OS-Linux OS-Mac OS-Windows
I can't reproduce this on Linux with v50.0.2661.102.

As far as I am aware, we don't automatically navigate on translate completion. We do send messages to the JavaScript layer about language detection and translation events, and in principle it might be somehow possible for the site developers to hook into these and try to navigate on behalf of the user:
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/resources/translate_internals/translate_internals.js

I don't see anything obvious in the handler c++ code that would indicate any kind of automatic navigation:
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc

Do you have any plugins installed that might be causing this behaviour?

Comment 4 by shie...@kkvesper.jp, May 25 2016

We've reproduced this on both Windows and Mac (two separate machines) so I doubt it's plugin related.

Here's screen-by-screen to reproduce, please confirm you've followed exactly:
Sorry, I misunderstood the original entry. Yes, this reproduces for me now. This looks like a problem with the "locale-select" logic in the page, which is obfuscated and minified and is best left to the page authors to debug. It seems likely that the javascript tries to get locale information out of a mapping it maintains internally and navigate to the right URL. I'd suggest digging into that logic to figure out what the mapping information is and how it is bound/read.

If you find that something in the browser's language information as exposed to the Javascript API is broken, that is something we can investigate; but it's equally likely at this point that it's a bug in the developer's script that is managing this transition.
PS - If your mapping is kept around in plain-text, like in a hidden div, it is entirely possible that the text is being translated. AFAIK translate should not touch any <script> blocks at all, nor should it translate href attributes etc.

Comment 7 by shie...@kkvesper.jp, May 25 2016

Hi Andrew thanks for investigating this.

Here's the relevant coffeescript for this (I'm the owner of the page)

    $('.locale-select').click (event)=>
      event.preventDefault()
      $target = @$(event.target)
      @storeLocale($target.data('locale'))
      window.location = $target.attr('href')

The problem is that $target.attr('href') is returning undefined; this only happens AFTER Chrome translate.

$target.prop('href') gives the same result.

Comment 8 Deleted

Comment 9 by shie...@kkvesper.jp, May 25 2016

OK this seems to work:

    $('.locale-select').click (event)->
      event.preventDefault()
      $target = LocaleDetect.$(@)
      LocaleDetect.storeLocale($target.data('locale'))
      window.location = $target.attr('href')

I guess Chrome Translate breaks jQuery's event.target?
Tested in win7, win10 & OSX 10.11.5 on stable version 51.0.2704.63 m. Looks issue fixed.
when click on "YES" navigating https://www.tablesolution.com/en/index.html
when click on "NO" nothing happend.

Thank you.

@mummare...@chromium.org

Actually I applied the workaround to the page. The bug still exists in Chrome. Here is a generic description:

1) If I have any element that contains translatable text
2) AND I add a jQuery event listener to that element, and the callback function references event.target
3) AND I click "Translate to English..." in Chrome
4) THEN when the callback function fires, any attempt to do $(event.target).attr('xxx') (where xxx is any HTML attribute) will return undefined.

As a workaround, calling $(this) instead of $(event.target) will allow you to fetch the data.
Got it, thanks for the clarification.
Cc: kenjibaheux@chromium.org groby@chromium.org
This might not be a bug in Chrome as such, but perhaps a side effect of the way that translation works. IIRC a script is downloaded from the Google Translate servers and it goes through and modifies the page content; it's conceivable that those modifications mess with the DOM elements in a way that makes jquery unhappy in this specific case (or more generally).

My expertise here is on how language detection functions.

Kenji, do you know who would be a better person to loop in on this?
Cc: chaotian@chromium.org
We've just received a suspiciously similar report in  issue 616744  saying that translate is altering CSS.
Cc: -kenjibaheux@chromium.org
Removing myself since I don't work on Translate anymore.

Comment 17 by ftang@chromium.org, Jun 29 2016

The code change need to from Google Translate Element. Internal bug id is 29872734

Comment 18 by ftang@chromium.org, Jun 29 2016

Summary: event handler depend on attribute of element break by translation (was: Chrome translation feature changes behavior of Javascript links)
rename this bug to "event handler depend on attribute of element break by translation"

Simplified example to show the problem
<html>
 <body>
   <span id=id1 love=good>text</span>
  <script>
   function myclick(event) {
     event.preventDefault();
     document.write("event.target: " + event.target.getAttribute("love") + "<br>");
     document.write("event.currentTarget: " + event.currentTarget.getAttribute("love") + "<br>");
     document.write("this: " + this.getAttribute("love") + "<br>");
     return true;
   }
   document.getElementById("id1").onclick=myclick;
  </script>
 </body>
</html>

Comment 19 by ftang@chromium.org, Jun 29 2016

Owner: ftang@chromium.org
Status: Assigned (was: Untriaged)
Project Member

Comment 20 by sheriffbot@chromium.org, Jul 8 2016

Labels: -M-53 M-54 MovedFrom-53
Moving this nonessential bug to the next milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: Hotlist-TranslateElement
Status: ExternalDependency (was: Assigned)
Cc: yyushkina@chromium.org ftang@google.com napper@chromium.org
Cc: reg@google.com barakt@google.com
Components: -UI>Browser>Translate UI>Browser>Language>Translate
Owner: kennetht@chromium.org
Status: assigned (was: ExternalDependency)
Owner: et@chromium.org
Owner: ----
Status: Available (was: Assigned)
Cc: anthonyvd@chromium.org

Sign in to add a comment