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

Can't test Angular2 apps on FireFox #2784

Closed
7-mb opened this issue Dec 16, 2015 · 17 comments
Closed

Can't test Angular2 apps on FireFox #2784

7-mb opened this issue Dec 16, 2015 · 17 comments

Comments

@7-mb
Copy link

7-mb commented Dec 16, 2015

After updating Angular JS 1.4.x to Angular 2, Selenium tests can't run anymore via grunt-protractor-runner on Firefox. As soon as AngularJS is loaded, the following error occurs (see Stackoverflow for details):

D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108
  var template = new Error(this.message);
                 ^
UnknownError: Permission denied to access property "toString"
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'NAGWS72', ip: '192.168.210.23', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
Driver info: driver.version: unknown
    at new bot.Error (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
    at Object.bot.response.checkResponse (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
    at D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
    at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
    at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
    at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
    at goog.async.run.processWorkQueue (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
    at process._tickCallback (node.js:366:9)
From: Task: <anonymous>
    at [object Object].pollCondition [as _onTimeout] (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2233:16)
    at Timer.listOnTimeout (timers.js:92:15)
From: Task: <anonymous wait>
    at [object Object].promise.ControlFlow.goog.defineClass.getSchedule.indent.wait (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2226:17)
    at [object Object].webdriver.WebDriver.wait (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:716:21)
    at [object Object].to.(anonymous function) [as wait] (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\protractor.js:65:25)
    at global.doLogin (D:\...\nisXplorerConfig.js:44:21)
    at exports.config.onPrepare (D:\...\nisXplorerConfig.js:79:9)
    at D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\util.js:54:41
    at Function.promise (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\q\q.js:650:9)
    at Object.exports.runFilenameOrFn_ (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\util.js:44:12)
    at [object Object].Runner.runTestPreparer (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\runner.js:76:17)
    at Object.exports.run (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\frameworks\jasmine.js:89:17)

So to isolate the problem I installed the sample Angular 2 Go with Protractor ! and got exactly the same error when I changed browserName: 'chrome' to firefox.

Thus I think this is an issue either by protractor or by selenium?

@alecxe
Copy link
Contributor

alecxe commented Dec 16, 2015

FYI, it is not related to a specific firefox version - I've tried with 38,39,40..43. Same problem.

@dnozay
Copy link

dnozay commented Dec 23, 2015

@jleyba may have some idea.

SeleniumHQ/selenium@0fa587d ?

@alecxe
Copy link
Contributor

alecxe commented Dec 24, 2015

@dnozay I've tried with the latest selenium (from the master branch) - same issue. Note that it also fails with directConnect - meaning that it is most likely the firefox-specific issue..thanks!

@dnozay
Copy link

dnozay commented Dec 24, 2015

created SeleniumHQ/selenium#1416 in case it is a selenium-webdriver issue.

@NickTomlin
Copy link
Contributor

@dnozay awesome, thanks for tracking this down!

@RomanHotsiy
Copy link

The same issue here.
I noticed this error appears only on the first query to the page. Fixed this by the following workaround:

beforeEach((done) => {
  browser.get(specUrl);
  $('body').isPresent().then(()=> {
    done();
  }, () => {
    //error skipped
    done();
  })
});

So before each test I do isPresent for body and skip error silently. After that all next queries work fine.

@Virginia770
Copy link

it works well in my code, thanks! :)

@juliemr
Copy link
Member

juliemr commented Jan 22, 2016

Per the discussion on selenium, this looks like something to do with how Angular2 is patching EventTargets.

@juliemr juliemr self-assigned this Jan 22, 2016
@juliemr juliemr added this to the 3.1 milestone Jan 22, 2016
@juliemr
Copy link
Member

juliemr commented Jan 23, 2016

Digging in further, I believe the problem is due to zone.js patching EventTarget#addEventListener here: https://github.com/angular/zone.js/blob/39b4a9129af9a07b07d7e86a09a040258019470a/lib/utils.ts#L84

That sets

obj.addEventListener = function (eventName, handler, useCapturing) {
    //Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150
    if (handler && handler.toString() !== "[object FunctionWrapper]") ....

The firefox-driver extension also uses addEventListener a lot, such as here: https://github.com/SeleniumHQ/selenium/blob/ab1e647d0fc8fc39e6b00ae94321ab228b6728f2/javascript/firefox-driver/js/evaluate.js#L64

I think the code from the normal site can't access properties from the code from the plugin because they're in different domains, but I need to learn more about Firefox's plugin permissions to debug further.

@juliemr
Copy link
Member

juliemr commented Jan 25, 2016

Minimal failing example at https://github.com/juliemr/zone-firefox-driver

@juliemr
Copy link
Member

juliemr commented Jan 25, 2016

I've filed an issue with zone.js: angular/zone.js#234

It may alternatively be possible to change FirefoxDriver to export the listener function from the driver's add-on content script to the page script, to avoid the permissions error, but it seems like the ball is in Zone's court since it's the one patching addEventListener.

@juliemr juliemr changed the title Can't run Protractor 3.0.0 on Firefox 38/42 after update to Angular 2 Can't test Angular2 apps on FireFox Jan 25, 2016
@juliemr juliemr modified the milestones: Blocked, 3.1 Feb 9, 2016
@xiehan
Copy link

xiehan commented Apr 26, 2016

I ran into this issue as well but it seems to have been fixed since upgrading to angular2-beta.15 (which includes the updates to Zone.js)

@nbuso
Copy link

nbuso commented Apr 27, 2016

  "dependencies": {
    "angular2": "2.0.0-beta.15",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "systemjs": "0.19.20",
    "zone.js": "^0.6.11"
  }

I still get the error:

Failed: Permission denied to access property "toString"

@BibbyChung
Copy link

BibbyChung commented Jun 3, 2016

@nbuso
I use the version. It's working..........

"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.11",
"bootstrap": "^3.3.6"
}

@juliemr
Copy link
Member

juliemr commented Jul 14, 2016

This is fixed in the latest zones.

@juliemr juliemr closed this as completed Jul 14, 2016
@KuchhalAnkit
Copy link

I am still getting timeout error in Firefox 47 and 48. Can someone please confirm if it is still an issue? Firebox browser is opening but test is not running and i get a timeout.

@nbuso
Copy link

nbuso commented Sep 15, 2016

I can for sure test on Firefox 47, I did not try 48. Is not an issue for me anymore

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