Maheshjayachandran / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

testcase.js doesn't handle global tests correctly in IE #413

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. write a unit test where you introduce tests explicitly on window - 
window.testSomethingInteresting = function() { ... }
2. Open the test in IE

What is the expected output? What do you see instead?
- Expected: The test should be executed and shown
- Actual: There is an error that no tests can be found

What version of the product are you using? On what operating system?
Issue appears in IE and it's not operating systems dependent.

Please provide any additional information below.

The bug is caused by a IE specific case in goog.testing.TestCase.getGlobals. It 
uses the nativity defined RuntimeObject to determine what global functions 
exist on window with the specified prefix. RuntimeObject specifically "only 
locates properties of the global object that were explicitly created by 
VariableStatement or FunctionDeclaration functions, or that were implicitly 
created by appearing as an identifier on the left side of an assignment 
operator" (http://msdn.microsoft.com/en-us/library/ff521039(v=vs.85).aspx) 
meaning it doesn't find functions explicitly declared on window.

I've patched the function and cleaned up 
goog.testing.TestCase.prototype.autoDiscoverTests which uses it. 
goog.testing.TestCase.prototype.autoDiscoverTests was basically duplicating 
code that should have existed in getGlobals.

In the process of fixing this bug I also found a bug in goog.typeOf that had to 
be fix to get goog.testing.TestCase working again.

goog.typeOf(globalStorage) throws a Security Error because of an IE specific 
hack which ends up calling globalStorage.length. I changed goog.typeOf to not 
use this hack on globalStorage since it doesn't apply and breaks goog.typeOf. I 
also added a test case for this.

See the attached patch that fixes both issues.

Original issue reported on code.google.com by kenstr...@gmail.com on 24 Jan 2012 at 10:18

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by chrishe...@google.com on 11 May 2012 at 7:54