⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 196961 in webkit


Ignore:
Timestamp:
Feb 22, 2016, 2:27:30 PM (11 years ago)
Author:
Chris Dumez
Message:

REGRESSION (r196563): Images not loading on ​https://klim.co.nz/blog/paypal-sans-design-information/
​https://bugs.webkit.org/show_bug.cgi?id=154547
<rdar://problem/24772167>

Reviewed by Gavin Barraclough.

Source/WebCore:

The Website was doing the following:
$ var e = window.addEventListener;
$ e("eventname", handler)

In such case, the jsEventTargetPrototypeFunctionDispatchEvent() bindings
implementation was caused with a thisValue which is a JSLexicalEnvironment
and the implementation did not know how to convert it into a global object.
The previous implementation on JSDOMWindow used to handle tis correctly
because it was always calling JSValue::toThis() on the thisValue before
trying to cast it to a JSDOMWindow, and JSLexicalEnvironment::toThis()
gets the globalThisValue. This patch updates the EventTarget bindings
code to call always call toThis() on the thisValue before trying to
cast it. This should correctly deal with JSLexicalEnvironment and be a
no-op in usual cases.

No new tests, extended existing test.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateFunctionCastedThis):

LayoutTests:

Add regression test for <rdar://problem/24772167>.

  • fast/dom/Window/addEventListener-implicit-this-expected.txt:
  • fast/dom/Window/addEventListener-implicit-this.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r196960 r196961  
     12016-02-22  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION (r196563): Images not loading on https://klim.co.nz/blog/paypal-sans-design-information/
     4        https://bugs.webkit.org/show_bug.cgi?id=154547
     5        <rdar://problem/24772167>
     6
     7        Reviewed by Gavin Barraclough.
     8
     9        Add regression test for <rdar://problem/24772167>.
     10
     11        * fast/dom/Window/addEventListener-implicit-this-expected.txt:
     12        * fast/dom/Window/addEventListener-implicit-this.html:
     13
    1142016-02-22  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this-expected.txt

    r196588 r196961  
    1111PASS xhrDispatchEventFunction.call(undefined, new Event('myevent')) is true
    1212PASS wasWindowEventListenerCalled is true
     13PASS addEventListenerFunction('myevent2', function() { wasWindowEventListenerCalled = true; }); did not throw exception.
     14PASS window.dispatchEvent(new Event('myevent2')) is true
     15PASS wasWindowEventListenerCalled is true
    1316PASS successfullyParsed is true
    1417
  • trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this.html

    r196588 r196961  
    3333shouldBeTrue("wasWindowEventListenerCalled");
    3434
     35wasWindowEventListenerCalled = false;
     36shouldNotThrow("addEventListenerFunction('myevent2', function() { wasWindowEventListenerCalled = true; });");
     37shouldBeTrue("window.dispatchEvent(new Event('myevent2'))");
     38shouldBeTrue("wasWindowEventListenerCalled");
     39
     40
    3541</script>
    3642<script src="../../../resources/js-test-post.js"></script>
  • trunk/Source/WebCore/ChangeLog

    r196960 r196961  
     12016-02-22  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION (r196563): Images not loading on https://klim.co.nz/blog/paypal-sans-design-information/
     4        https://bugs.webkit.org/show_bug.cgi?id=154547
     5        <rdar://problem/24772167>
     6
     7        Reviewed by Gavin Barraclough.
     8
     9        The Website was doing the following:
     10        $ var e = window.addEventListener;
     11        $ e("eventname", handler)
     12
     13        In such case, the jsEventTargetPrototypeFunctionDispatchEvent() bindings
     14        implementation was caused with a thisValue which is a JSLexicalEnvironment
     15        and the implementation did not know how to convert it into a global object.
     16        The previous implementation on JSDOMWindow used to handle tis correctly
     17        because it was always calling JSValue::toThis() on the thisValue before
     18        trying to cast it to a JSDOMWindow, and JSLexicalEnvironment::toThis()
     19        gets the globalThisValue. This patch updates the EventTarget bindings
     20        code to call always call toThis() on the thisValue before trying to
     21        cast it. This should correctly deal with JSLexicalEnvironment and be a
     22        no-op in usual cases.
     23
     24        No new tests, extended existing test.
     25
     26        * bindings/scripts/CodeGeneratorJS.pm:
     27        (GenerateFunctionCastedThis):
     28
    1292016-02-22  Simon Fraser  <simon.fraser@apple.com>
    230
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r196954 r196961  
    32653265            # We allow calling the EventTarget API without an explicit 'this' value and fall back to using the global object instead.
    32663266            # As of early 2016, this matches Firefox and Chrome's behavior.
    3267             push(@implContent, "    auto castedThis = thisValue.isUndefinedOrNull() ? $castingHelper(thisValue.toThis(state, NotStrictMode)) : $castingHelper(thisValue);\n");
     3267            push(@implContent, "    auto castedThis = $castingHelper(thisValue.toThis(state, NotStrictMode));\n");
    32683268        } else {
    32693269            push(@implContent, "    auto castedThis = $castingHelper(thisValue);\n");
Note: See TracChangeset for help on using the changeset viewer.