protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Firefox - Failed: SecurityError: The operation is insecure

Open jcugmas opened this issue 8 years ago • 3 comments

Bug report

  • Node Version: 5.5.1
  • Protractor Version: 5.2.2
  • Angular Version: 1.6.4
  • Browser(s): Firefox 58.0
  • Operating System and Version Linux - Ubuntu 16.04 LTS

My configuration file

const config = {
    baseUrl: 'http://localhost:3330/',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    capabilities: {
        browserName: 'firefox'
    },
    framework: 'jasmine2',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 600 * 1000,
        // remove ugly protractor dot reporter
        print: () => {}
    },
    specs: ['./test/e2e/specs/**/*.spec.js'],
    onPrepare: () => {
        require("babel-core/register")({
            presets: [
                "es2015"
            ]
        });
        const helper = require('./test/e2e/helpers.js');
        browser._ = new helper.Helper();
        browser._CommonPageObject = helper.CommonPageObject;
        jasmine.getEnv().addReporter(reporter);
    },
    params: {
        timeout: 10000
    }
};

A snapshot my spec test firing the error

beforeAll(()=>{
        browser.executeScript(function () {
            window.localStorage.auth = {
                token:'XXXXXXXXXXXXXXXXXXX',
                expirationDate: new Date().getTime() + 3600000
            };
        });
        page = new ContactsPage();
        page.load();
});

To resume you my problem, I want to test with protractor my project which is a platform for clients, so controlled by a login page. The login request responses me a token with a expiration date which I store on the localStorage of my browser. The fact is I don't want to make all my pages (available after the login step) depend of the login page. So the idea which came to me was to set the token in the localStorage of my browser in the beforeAll method of all my specs file of the pages under the login one. But when protractor ended all these tests, I can see on the HTML report the following error for the pages under login :

Failed: SecurityError: The operation is insecure. Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z' System info: host: 'XXXXX', ip: 'XXX.X.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '4.13.0-32-generic', java.version: '1.8.0_151' Driver info: driver.version: unknown

So I want your help and ask you if, firstly, is it the best practice to do that ? You think I should let these pages depend on login and do the login process before each page test ? And secondly, do you think this is an error directly linked to Firefox ? Can I disable this security ? I saw that is possible to create some firefox profiles but I am lost on all these permissions and options.

Thanks !

Sorry for my english, french guy here !

jcugmas avatar Feb 01 '18 14:02 jcugmas

Hi, @jcugmas ! I have tried to run code snippet and it works as expected. First of all, browser.executeScript() returns promise. You need to resolve it as follow: browser.executeScript(

Owner


Other Repo Issues