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

Injected Chrome Extensions fail to load #876

Closed
radiovisual opened this issue Nov 6, 2017 · 3 comments
Closed

Injected Chrome Extensions fail to load #876

radiovisual opened this issue Nov 6, 2017 · 3 comments

Comments

@radiovisual
Copy link

radiovisual commented Nov 6, 2017

  • Operating System: MacOS 10.13
  • Cypress Version: 1.0.3
  • Browser Version: Chrome 61

Is this a Feature or Bug?

Bug.

Current behavior:

When I load a Chrome Extension (per the instructions here) the Chrome Extension icon is visible in the corner of the Cypress-controlled version of Chrome, however, the extension does not load itself into the page, and I get the following errors:

[Report Only] Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'report-sample' 'nonce-TiA4mI9l8sD4SFX78BmSxUaNCNc' 'unsafe-inline' 'strict-dynamic' https: http: 'unsafe-eval'". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.
Refused to display 'https://accounts.google.com/ServiceLogin?passive=1209600&osid=1&continue=https://notifications.google.com/u/0/widget?sourceid%3D24%26hl%3Den%26origin%3Dhttps://calendar.google.com%26uc%3D1%26usegapi%3D1%26jsh%3Dm;/_/scs/abc-static/_/js/k%253Dgapi.gapi.en.-B1JI5BnpkY.O/m%253D__features__/am%253DAAQ/rt%253Dj/d%253D1/rs%253DAHpOoo-J_489p3irekFx--jdEVsS-UunRg&followup=https://notifications.google.com/u/0/widget?sourceid%3D24%26hl%3Den%26origin%3Dhttps://calendar.google.com%26uc%3D1%26usegapi%3D1%26jsh%3Dm;/_/scs/abc-static/_/js/k%253Dgapi.gapi.en.-B1JI5BnpkY.O/m%253D__features__/am%253DAAQ/rt%253Dj/d%253D1/rs%253DAHpOoo-J_489p3irekFx--jdEVsS-UunRg&hl=en&authuser=0#pid=24&_methods=onError%2ConInfo%2ChideNotificationWidget%2CpostSharedMessage%2Creauth%2CsetNotificationWidgetHeight%2CsetNotificationWidgetSize%2CswitchTo%2CnavigateTo%2CsetNotificationText%2CsetNotificationAnimation%2CgetNotificationText%2CvalidateUser%2C_ready&id=I1_1509956950239&_gfid=I1_1509956950239&parent=https%3A%2F%2Fcalendar.google.com&pfname=&rpctoken=92871221' in a frame because it set 'X-Frame-Options' to 'deny'.
Failed to load resource: net::ERR_BLOCKED_BY_RESPONSE

Desired behavior:

When I install a Chrome Extension that injects contents into the current page, I expect to be able to interact with the injected contents of the Chrome Extension

How to reproduce:

  1. Install the Meekan Chrome Extension into your Cypress Browser
  2. Open Google Calendar
  3. Click "Create Event"
  4. Open the console, and you will see the errors above

Test code:

describe('Create a new Meeting', function() {
    it('.should() - load suggestions on a new meeting', function () {
        cy.visit('https://calendar.google.com/calendar');
        cy.get('div[jsname="EcotYb"] div[role="button"]').click();
        
        cy.wait(3000); // Generous wait for the extension to load
        cy.get('div.timeslot').find('span.status-info').should('have.length', 4);
    })
});

Additional Info (images, stack traces, etc)

If the Chrome Extension loaded successfully, this is what you would see:

image

Or if you have connected your Calendar to Meekan, this is what you would see:

image


**UPDATE (Nov 9 2017): I removed the Google Login from the test code, it was not relevant to the problem, it was only there as a helper to anyone who might be trying to troubleshoot the problem.

@brian-mann
Copy link
Member

I'm trying to separate out what you're trying to do vs what should be working.

From a cursory glance, it seems as if the extension parts of your issue is not actually the real issue. It seems that you're trying to visit 3rd party sites to do your OAuth login.

That is not supported - you'll need to use google's programmatic API's directly and avoid logging in through them.

We have a comprehensive explanation here: https://docs.cypress.io/guides/references/best-practices.html#Visiting-external-sites

Additionally, we have several recipes showing you how to handle SSO type logins.

@jennifer-shehane jennifer-shehane added pkg/extension This is due to an issue in the packages/extension directory stage: needs information Not enough info to reproduce the issue and removed pkg/extension This is due to an issue in the packages/extension directory labels Nov 6, 2017
@radiovisual
Copy link
Author

radiovisual commented Nov 6, 2017

Ah, thanks for the explanation, but its actually not the Google login that is the problem, I only have that code to login via Google as a helper (but in the end, its not that useful), the problem is that when I am logged into Google Calendar via Cypress, it blocks every attempt to load the Chrome Extension into the page. So I dont think Google is the problem here. The Chrome Extension is asking for data from a (non-Google) API, but the Chrome Extension loads fine everywhere in Chrome EXCEPT from inside of the Cypress-controlled Chrome.

@kuceb
Copy link
Contributor

kuceb commented Dec 18, 2018

Hi @radiovisual, please follow this issue here for our chrome extension support

There is an example of testing an extension that injects into the DOM of gmail.

#1965

@kuceb kuceb closed this as completed Dec 18, 2018
@kuceb kuceb added type: question and removed stage: needs information Not enough info to reproduce the issue labels Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants