Bug 71416

Summary: Improve shouldThrow from js-test-pre.js
Product: WebKit Reporter: Erik Arvidsson <arv>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Erik Arvidsson 2011-11-02 16:15:22 PDT
Currently we do an == to compare the expected exception. It would be good if we could pass a constructor and do an instanceof check instead,

Currently:

shouldThrow('localStorage.key()', '"TypeError: Not enough arguments"')

It would be useful to allow this too

shouldThrow('localStorage.key()', 'TypeError')

which would do an instanceof check instead.

We could even go one step further and also allow checking the message of the exception:

shouldThrow('localStorage.key()', 'TypeError', '"Not enough arguments"')

The benefit is that this would work better on different browsers where the toString of the exception does not match what we do in WebKit.
Comment 1 Alexey Proskuryakov 2011-11-03 11:27:31 PDT
Great idea!