Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$window mocking not working without document since 1.3.0 #9661

Closed
tjokimie opened this issue Oct 17, 2014 · 3 comments · Fixed by #9663
Closed

$window mocking not working without document since 1.3.0 #9661

tjokimie opened this issue Oct 17, 2014 · 3 comments · Fixed by #9663

Comments

@tjokimie
Copy link

I have tests for a directive that uses $window. Since 1.3.0 I cannot mock $window without having document property in $window.

I have a JSFiddle demonstrating this problem:

@gkalpak
Copy link
Member

gkalpak commented Oct 17, 2014

It is because of this line https://github.com/angular/angular.js/blob/master/src/ng/sce.js#L725 (obviously :))
It seems logical to me that the global msie should be used instead.

Do I miss something ? Is there anything special about $sce that has to use $document[0] instead ?

BTW, is it possible to mock msie if someone needs to ?

@shahata
Copy link
Contributor

shahata commented Oct 17, 2014

Hmmm, you are probably right about msie, I'll look into it.

@shahata
Copy link
Contributor

shahata commented Oct 17, 2014

Yeah, the other option is to fiddle with the msie global in the test or add some way to mock it. All the other places where we test code that uses msie, we don't mock it, we just run the additional/modified test in IE for real. In this case, we can't do that since karma always has <!doctype html> in the runner document. So actually, this is the only place I found in angular where msie needs to mocked, so I think it is not worth it and I prefer the PR just the way it is.

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

Successfully merging a pull request may close this issue.

3 participants