New issue
Advanced search Search tips

Issue 617178 link

Starred by 3 users

Issue metadata

Status: Archived
Owner:
Closed: Dec 5
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug-Regression



Sign in to add a comment

CommandLineAPI methods doesn't work when they are redefined in page context

Reported by nikhilv2...@gmail.com, Jun 3 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36

Steps to reproduce the problem:
1. Navigate to meetup.com
2. open devtools >> console tab
3. enter inspect(document.getElementById('mainNav')) and press enter key

What is the expected behavior?
should highlight the element on 'Elements' panel(tab)

What went wrong?
returns undefined

Did this work before? N/A 

Chrome version: 51.0.2704.79  Channel: stable
OS Version: 6.3
Flash Version: Shockwave Flash 21.0 r0

meetup is a site where inspect() doesn't seem to work
 
Labels: -OS-Windows -Type-Bug OS-All Type-Bug-Regression
Status: Untriaged (was: Unconfirmed)
Confirmed on 52.0.2743.19 as well.

`inspect` seems to be an empty function in the console. While on crbug it provides the proper output `function inspect(object) { [Command Line API ] }`, but doing something like `inspect($('.issueheader'))` returns null and does nothing.

Marking as a regression bug. Thanks for the great report.
Labels: Needs-Feedback
Owner: kozyatinskiy@chromium.org
Status: Assigned (was: Untriaged)
Summary: CommandLineAPI methods doesn't work when they are redefined in page context (was: inspect function doesn't work on meetup.com)
Meetup.Global = function(){
	if (typeof(IS_DEV) == 'undefined'){
		this.IS_DEV = false;
	}
	if (typeof(IS_QA) == 'undefined'){
		this.IS_QA = false;
	}
	if (typeof(LOG) == 'undefined'){
		this.LOG = { 'info': function() { return; }, 'error':function() { return; } };
		this.inspect = function(){};
	}
};

meetup.com override inspect function on global object and we don't override it with CommandLineAPI one.

So works as intended. I think we can provide another way to call CommandLineAPI methods in console. I won't close it right now and wait some time to get more feedback from users.
I'm using this cmd in one of my extension. If the site is overriding this cmd, the functionality breaks. what would be the workaround for me to avoid it.
 Issue 657700  has been merged into this issue.

Comment 5 by phistuck@gmail.com, Oct 20 2016

Please, add those methods and properties to the console namespace somehow. Also -
var console = 0;
Ruins things as well. There should be a way to call those regardless of page definitions.
Labels: Hotlist-Polish
Cc: dgozman@chromium.org
Status: WontFix (was: Assigned)
Here is magic workaround, in console you can run following commands to get command line api method (inspect for example):
> var pageInspect = inspect; delete inspect;
> dtInspect = inspect;
> inspect = pageInspect; delete pageInspect;
> dtInspet(..element..);

each line should be evaluated separately, pageInspect should not he defined in page context before evaluation (you can use any other variable name if it's defined), after running each command dtInspect will contains DevTools command line API inspect method.

Comment 8 Deleted

Cc: -kayce@chromium.org kayce@google.com
Kayce, do we have web page which describes command line API, can we put this workround there?
Note that we could detect that some of command line api functions are overridden and show an info badge with a link.
Status: Assigned (was: WontFix)

Comment 12 by phistuck@gmail.com, Oct 14 2017

Also, why are those not added to the console object as well (or some other umbrella object that is only available in the Developer Tools)?
This way, you would get all of those APIs by just getting back that object instead of going over all of the separate APIs and using that workaround for each of them. Plus, developers could query that object and see all of the options that the API provides (that object and console, but better than console and window, where you have many global members that are unrelated to the Developer Tools).
It could have a long name (commandLineAPI), because it would only be used as a workaround/a way to query the API.
These methods are not designed to be available all the time (like in case if we expose them on console object) and there is no way to introduce something with guarantee that user won't override it since our code should be executed at the same environment as any script in page context - and anything can be defined there (including commandLineAPI object).
We will detect that method is overriden and provide single click action which will return requested method in temporary variable.

Comment 14 by phistuck@gmail.com, Oct 15 2017

What about the second use case (enumerating the APIs)?
Owner: kozy@chromium.org
Status: Archived (was: Assigned)
Bulk-closing low priority bugs / feature requests with no action plan.

Sign in to add a comment