Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

$a console command sometimes throws an error #684

Closed
hilaryhacksel opened this issue Sep 19, 2016 · 3 comments
Closed

$a console command sometimes throws an error #684

hilaryhacksel opened this issue Sep 19, 2016 · 3 comments
Labels

Comments

@hilaryhacksel
Copy link
Contributor

Steps to reproduce:

  1. Open a new tab and make sure your developers tools window is closed.
  2. Navigate to your angular app (or https://augury.angular.io/demo/#/).
  3. Open your developers tools and pick the Augury tab.
  4. Click on some Angular component.
  5. Type $a into the console and press enter
    -> produces the error: Uncaught ReferenceError: $a is not defined(…)

However, $a is defined if your developer tools is open before navigating to the angular app.

@xorgy xorgy added the bug label Sep 20, 2016
@orizens
Copy link

orizens commented Sep 28, 2016

hi @hilaryhacksel
I investigated this issue.
It seems like the 'window' referenced within the consoleReference function is not the actual window of the relevant tab.
This is caused of a limitation with content scripts as described here
It seems like the proper solution would be to use postMessage to interact with the Tab's window object and set the '$a' property there.

@stevenkampen
Copy link
Contributor

stevenkampen commented Oct 6, 2016

Ok, I am able to reproduce this reliably now, and to do that I had to include the following steps:

  1. Make sure you are signed OUT of Chrome.
  2. Open the dev tools with "Inspect Element", rather than CMD + Shift + I.

A cache refresh was not required but the quitting chrome and opening again is.

@stevenkampen
Copy link
Contributor

stevenkampen commented Oct 7, 2016

@orizens I think I've found at least the superficial cause of this error. At least it worked for me and for @hilaryhacksel. It might make you laugh but in the end it was just that the incorrect console "context" is selected. It should be "top" as in the screenshot below, but I found that mine had been changed to the extension context. Please confirm if this is describes your situation also.

screen shot 2016-10-07 at 4 09 09 pm

I'm thinking now about how to mitigate this annoyance with some proactive hinting in the console.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants