Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JS instrument test #291

Merged
merged 3 commits into from
Apr 26, 2019
Merged

Fix JS instrument test #291

merged 3 commits into from
Apr 26, 2019

Conversation

nhnt11
Copy link
Contributor

@nhnt11 nhnt11 commented Apr 25, 2019

The fix is in 2 parts:

  1. The function argument lists are now stored as JSON arrays and we need to modify our expected values accordingly.
  2. window.instrumentObject is not exposed unless we pass testing=true to the content script. We need to find a way to reliably pass this based on config['testing']

@nhnt11 nhnt11 requested a review from englehardt April 25, 2019 15:57
@nhnt11
Copy link
Contributor Author

nhnt11 commented Apr 25, 2019

@englehardt I thought of a few ways to expose the 'testing' config flag to the content script, but they're all asynchronous (the storage API is the most straightforward), which results in the page script not getting injected in time (i.e. scripts in the page being loaded run before we inject our instrumentation).

One way to get around this is for the tests to use a special build of the add-on with the testing flag hard-coded where necessary, but this feels a bit complicated.

A quick-fix, for now, would be to just always set testing=true for the JS instrumentation. The only effect this currently has is to expose instrumentObject in the scope of the window for tests to use, and a cosmetic console message saying that we're in testing mode, every time the page script loads.

What do you think? I recommend the quick-fix, and if our future content-script work gives us a way to do this better, we can implement it then.

@nhnt11
Copy link
Contributor Author

nhnt11 commented Apr 25, 2019

I went ahead and pushed a commit to this PR that enables testing-mode by default for the page script. Feel free to merge this if you're okay with this solution (and r+)

@englehardt
Copy link
Collaborator

I think the quick fix is okay for now, but we will need to solve this problem eventually. See #289 (comment) and #68. I think the bugs linked in #242 include an approach that will work for Firefox.

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

Successfully merging this pull request may close these issues.

2 participants