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

fix(ngMock window.inject): Remove Error 'stack' property changes #5047

Closed
wants to merge 1 commit into from

Commits on Nov 20, 2013

  1. fix(ngMock window.inject): Remove Error 'stack' property changes

    Recent browsers, particularly PhantomJS 1.9.2 and Safari 7.0
    treat the stack property as non-configurable and unwritable.
    
    Because window.inject captures the stack at the time of the inject,
    and attempts to insert it into a captured throw from the injected
    function by modifying e.stack, a meaningless error message and
    stack is thrown instead.
    
    This commit inserts two tests exposing the problem, and implements
    a proposed solution that builds a new error-like object that mimicks
    the old Error object, but with the additional stack information, and
    captures the toString function from the Error object prototype.  This
    appears to work for the browsers suppoerted here.
    
    An exception is IE8 or less, which fails to yield meaningful messages
    under both the status quo and after this commit.  Accordingly, the test
    memorializes the current behavior without throwing an error for IE8
    and earlier.
    
    modified:   src/ngMock/angular-mocks.js
    modified:   test/ngMock/angular-mocksSpec.js
    wizardwerdna committed Nov 20, 2013
    Configuration menu
    Copy the full SHA
    1751576 View commit details
    Browse the repository at this point in the history