• Raphael Kubo da Costa's avatar
    Remove toString() override from DOMException. · be24cfe8
    Raphael Kubo da Costa authored
    Adapt to https://github.com/heycam/webidl/pull/378 ("Re-align DOMException
    objects with what is implemented").
    
    We were reimplementing toString() in DOMException because of WebKit
    r29058 ("Acid3 expects ExeceptionCode constants to be defined on
    DOMException objects") from almost 10 years ago. A lot has happened since,
    and we can (and should) just use the toString() implementation from
    ECMAScript's %ErrorProtoype% (which is explicitly mandated to be in
    DOMException's inheritance chain by the WebIDL spec).
    
    Contrary to what's originally described in bug 556950, we do throw an
    exception when DOMException.prototype.toString() is called directly: the
    WebIDL spec now expects it to, and
    https://github.com/w3c/web-platform-tests/pull/6361 tests this behavior.
    
    Additionally, we've changed the way DOMException inherits from
    %ErrorPrototype%: instead of doing it in V8PerContextData, we now do it in
    V8DOMException::installV8DOMExceptionTemplate(), as the former had problems
    with (i)frames detached from the DOM and toString() would just call
    Object.prototype.toString() instead.
    
    The only user-visible part of the change is that "toString" is no longer
    part of DOMException.prototype's own properties; the error message format is
    exactly the same in most cases (the exact steps are described in
    https://tc39.github.io/ecma262/#sec-error.prototype.tostring).
    
    Finally, part of http/tests/plugins/cross-frame-object-access.html's
    output will change from:
        "Error: Uncaught [object DOMException]"
    to
        "Error: Uncaught"
    This is tricky because it involves PPAPI and its separate process, but
    basically the plugin in an iframe is trying to access top.location.href,
    Blink is throwing a SecurityError, but the error message is sent truncated
    to PPAPI. The message is truncated because V8 is calling its
    NoSideEffectsErrorToString() when creating the message, and this one does
    not use the message/name accessors we install, leading to an empty message
    (it looked slightly better before because we the presence of our own
    toString() caused Object::NoSideEffectsToString() to choose a different
    albeit still wrong code path). Blink's handling of this is fine, as the
    code in V8Initializer takes care of extracting the name and error message
    from the DOMException V8 object that threw the exception.
    
    Bug: 556950, 737497
    Change-Id: I9d81edca1de903364bb1aca5950c313885c5964a
    Reviewed-on: https://chromium-review.googlesource.com/558904
    Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
    Reviewed-by: default avatarMike West <mkwst@chromium.org>
    Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
    Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#485960}
    be24cfe8
plaintext-length-expected.txt 387 Bytes