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

Allow XHR interceptor in local development mode #22746

Merged
merged 3 commits into from Jun 14, 2019
Merged

Allow XHR interceptor in local development mode #22746

merged 3 commits into from Jun 14, 2019

Conversation

alabiaga
Copy link
Contributor

@alabiaga alabiaga commented Jun 7, 2019

follow up to addressing #22600 (comment)

-allow xhr interceptor in local dev mode and not in validation development mode.
-add viewer xhrInterceptor example.

@alabiaga alabiaga changed the title allow intercepting in non development mode allow intercepting in local development mode Jun 10, 2019
@alabiaga
Copy link
Contributor Author

cc\ @zhangsu closed the PR with the json handling change and just went the route of doing the json in the response body as a string. Just an FYI, thanks for your review.

@alabiaga alabiaga changed the title allow intercepting in local development mode allow XHR interceptor in local development mode Jun 10, 2019
@alabiaga alabiaga changed the title allow XHR interceptor in local development mode Allow XHR interceptor in local development mode Jun 10, 2019
@alabiaga
Copy link
Contributor Author

cc\ @fstanis xhrInterceptor example. Will port over same changes to our partner dev code as it'll be cleaner and less noisy of an example.

@alabiaga
Copy link
Contributor Author

@choumx Hey Will when you get a chance. Thanks

sandbox.stub(viewer, 'isTrustedViewer').returns(Promise.resolve(false));
interceptionEnabledWin.AMP_DEV_MODE = true;
sandbox.stub(mode, 'getMode').returns({localDev: true});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set test.win.AMP_MODE = {localDev: true}; to avoid the wildcard import.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is actually not enclosed in the scenario test cases which mocks the window obj which is specific to testing native vs polyfill fetch, so this wouldn't work. Thanks for the input though.

@alabiaga alabiaga merged commit fe602a0 into ampproject:master Jun 14, 2019
@alabiaga alabiaga deleted the fix-intercept-response-logic branch June 14, 2019 02:08
thekorn pushed a commit to edelight/amphtml that referenced this pull request Sep 11, 2019
* allow intercepting in non development mode

* allow xhr intercept in local dev mode. add example for xhr intercept

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

Successfully merging this pull request may close these issues.

None yet

3 participants