New issue
Advanced search Search tips

Issue 668047 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

cannot get ParentNode.prototype.querySelector at initial parser sees <html> tag

Reported by ctengc...@gmail.com, Nov 23 2016

Issue description

Steps to reproduce the problem:
Background: we are building a AdBlocker module on android using a custom embedder, and use WebView.evaluateJavaScript to inject js code to remove ad popup elements.

Due to DOM prototype may be overridden by site js code, we imported Opera's `sitepatcher` module for the purpose of injecting js. The basic idea is: keep the original DOM prototype method refs when html parser first sees <html> tag, when site js code is still not yet imported.

However, it turns out we cannot get querySelector ref by Document.prototype.querySelector or ParentNode.prototype.querySelector, but we can get removeChild by Node.prototype.removeChild.

querySelector's internal binding wrapper mechanism seems to be no different than querySelector, i cannot figure out why?

What is the expected behavior?

What went wrong?
Should be able to get DOM method querySelector ref by ParentNode.prototype.querySelector or Document..prototype.querySelector at early initialization stage(when html parser sees the <html> tag)
But can't.

But removeChild is no problem.

Did this work before? No 

Chrome version: 43.0.2357.134  Channel: stable
OS Version: 5.1
Flash Version:
 

Comment 1 by ctengc...@gmail.com, Nov 23 2016

As to the original requirement, we bypass the bug by use evaluateJavaScriptInIsolatedWorld API. v8 isolate runs a different JS context, which site js cannot modify the default DOM methods.

But i wish to know why the previous method doesn't work?

Comment 2 by ctengc...@gmail.com, Nov 23 2016

Sorry typo:

querySelector's internal binding wrapper mechanism seems to be no different than querySelector,

should be

querySelector's internal binding wrapper mechanism seems to be no different than removeChild,


Components: -Blink Blink>Bindings
Status: WontFix (was: Unconfirmed)
ParentNode doesn't have any public exposure, so that isn't intended to work.

Can't reproduce the rest at ToT; I wrote a content script that injects at document start that prints Document.prototype.querySelector and Node.prototype.removeChild, and they both exist:

function querySelector() { [native code] }
function removeChild() { [native code] }

Sign in to add a comment