Is it possible to blackbox all VM scripts in chrome debugger?
Asked Answered
F

2

39

I'm trying to debug quite a complicated module in my angular app. I've set a break point at the start of a particular method hoping I could follow it through and see where it's giving me back an error. However, it keeps bringing me into the VM scripts (VM28337, VM30559, etc). I can assume these all work as they should, so I have no interest in seeing them.

I know I can blackbox certain scripts in chrome debugger, but there seems to be an endless amount of these VM scripts. Does anyone have any suggestions on how to circumvent these scripts?

Flatto answered 27/4, 2015 at 13:53 Comment(6)
the VM scripts are code that is pulled in dynamically by an ajax request so they are not labeled with their file name. I am also looking for a way to do this. VM* is not working...Mcwilliams
This also is not working: ^VM/\b\d{5}\b/gMcwilliams
Thanks for letting me know. I was just about to go down the reg-exp rabbit hole.Flatto
Any luck on this? I've been looking for a solution for a while. Usually you can right-click on the script and blackbox it there, but the menu is not there on these types of scripts.Nervine
To my knowledge there is no way to do this. It would be a nice to have as part of the blackboxing feature. I'd recommend making a ticket on crbug.com for itHist
Just to confirm, what you want is for the console.log() to not display the source where it came from, correct (i.e. VM300:1 for instance)Polymath
S
11

This doesn't appear to be possible in any version of Chrome at the moment. However, I create a Chromium bug to request it get added: Chromium Issue 526239

Stria answered 28/8, 2015 at 19:14 Comment(2)
It's been merged into a different issue - bugs.chromium.org/p/chromium/issues/detail?id=632513&desc=4. Still no solution for this, and it doesn't look like you can do it in Firefox or IEAdvanced
Any further news on this?Recitation
M
2

A development-time-only workaround can be to override eval in your page -

(function ()
 {
  var originalEval = eval;
  eval =
   function (script)
   {
    return originalEval(script + "\n//# sourceURL=blackbox-this.js");
   }
 }());

And then blackbox ^.*blackbox-this.js$

Same for setInterval/setTimeout when it gets a string (but that is a bad practice anyway, right? ;))

Does that work for you?

Morly answered 9/8, 2017 at 16:10 Comment(4)
how exactly? i didn't succeed in following. how i use this to make DevTools stop debugging VM### ?Afroamerican
@Afroamerican - this needs to be the first script on the page (and this assumes the code that generates those VM### uses eval, otherwise, you need to override other means, like setTimeout, Function if possible and friends).Morly
This didn't work for a angularjs app at least, there are still some VM's that don't have the injected sourceURL. Also it should check if a sourceURL already exists in that script, so dev can control what to show or not.Hurtful
@Z.Khullah - I guess they are using other ways to evaluate the code, then. Like new Function(...) or injecting a <script>code</script>.Morly

© 2022 - 2024 — McMap. All rights reserved.