<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>199540</bug_id>
          
          <creation_ts>2019-07-05 19:21:41 -0700</creation_ts>
          <short_desc>Carvana.com needs the fetch AbortSignal quirk</short_desc>
          <delta_ts>2019-07-05 22:37:44 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore JavaScript</component>
          <version>Safari Technology Preview</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Zhifei Fang">zhifei_fang</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>achristensen</cc>
    
    <cc>cdumez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
    
    <cc>zhifei_fang</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1550600</commentid>
    <comment_count>0</comment_count>
    <who name="Zhifei Fang">zhifei_fang</who>
    <bug_when>2019-07-05 19:21:41 -0700</bug_when>
    <thetext>In this website: https://www.carvana.com/vehicle/1251874

They use a polyfill for abort signal, I guess the reason is here:
https://bugs.webkit.org/show_bug.cgi?id=174980

Though we already fix this, I guess for a compatible reason, they just do a polyfill for safari everywhere without checking safari&apos;s version.


here is the code:

```
                 a = function(e) {
                    function a() {
                        t(this, a);
                        var e = n(this, (a.__proto__ || Object.getPrototypeOf(a)).call(this));
                        return e.aborted = !1, e.onabort = null, e
                    }
                    return function(e, t) {
                        if (&quot;function&quot; !== typeof t &amp;&amp; null !== t)
                            throw new TypeError(&quot;Super expression must either be null or a function, not &quot; + typeof t);
                        e.prototype = Object.create(t &amp;&amp; t.prototype, {
                            constructor: {
                                value: e,
                                enumerable: !1,
                                writable: !0,
                                configurable: !0
                            }
                        }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
                    }(a, i), r(a, [{
                        key: &quot;toString&quot;,
                        value: function() {
                            return &quot;[object AbortSignal]&quot;
                        }
                    }, {
                        key: &quot;dispatchEvent&quot;,
                        value: function(e) {
                            &quot;abort&quot; === e.type &amp;&amp; (this.aborted = !0, &quot;function&quot; === typeof this.onabort &amp;&amp; this.onabort.call(this, e)), function e(t, r, n) {
                                null === t &amp;&amp; (t = Function.prototype);
                                var i = Object.getOwnPropertyDescriptor(t, r);
                                if (void 0 === i) {
                                    var a = Object.getPrototypeOf(t);
                                    return null === a ? void 0 : e(a, r, n)
                                }
                                if (&quot;value&quot; in i)
                                    return i.value;
                                var o = i.get;
                                return void 0 !== o ? o.call(n) : void 0
                            }(a.prototype.__proto__ || Object.getPrototypeOf(a.prototype), &quot;dispatchEvent&quot;, this).call(this, e)
                        }
                    }]), a
                }(),
                o = function() {
                    function e() {
                        t(this, e), this.signal = new a
                    }
                    return r(e, [{
                        key: &quot;abort&quot;,
                        value: function() {
                            var e = void 0;
                            try {
                                e = new Event(&quot;abort&quot;)
                            } catch (t) {
                                &quot;undefined&quot; !== typeof document ? (e = document.createEvent(&quot;Event&quot;)).initEvent(&quot;abort&quot;, !1, !1) : e = {
                                    type: &quot;abort&quot;,
                                    bubbles: !1,
                                    cancelable: !1
                                }
                            }
                            this.signal.dispatchEvent(e)
                        }
                    }, {
                        key: &quot;toString&quot;,
                        value: function() {
                            return &quot;[object AbortController]&quot;
                        }
                    }]), e
                }();
            &quot;undefined&quot; !== typeof Symbol &amp;&amp; Symbol.toStringTag &amp;&amp; (o.prototype[Symbol.toStringTag] = &quot;AbortController&quot;, a.prototype[Symbol.toStringTag] = &quot;AbortSignal&quot;), function(e) {
                if (!e.AbortController || function(e) {
                    return e.navigator &amp;&amp; (e.navigator.vendor &amp;&amp; e.navigator.vendor.startsWith(&quot;Apple Computer&quot;) || e.navigator.userAgent &amp;&amp; e.navigator.userAgent.match(/ (crios|gsa|fxios)\//i))
                }(e))
                    if (e.AbortController = o, e.AbortSignal = a, e.fetch) {
```

in here, e is the window, they are using a self defined object (a, o) to replace webkit&apos;s AbortContorller and AbortSignal


And in FetchRequest::initialWith 

    if (init.signal) {
        if (auto* signal = JSAbortSignal::toWrapped(scriptExecutionContext()-&gt;vm(), init.signal))
            m_signal-&gt;follow(*signal);
        else if (!init.signal.isUndefinedOrNull())  {
            if (auto exception = processInvalidSignal(*scriptExecutionContext()))
                return WTFMove(*exception);
        }
    }

We do a JSAbortSignal::toWrapped, this will do a jscDynamicCast, since here it has been replaced by the polyfill, we cannot do that. In result, we have an exception here.

I guess to allow this polyfill, we should call the AbortSignal&apos;s interface in js, rather than dynamic cast it here</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1550601</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2019-07-05 19:56:00 -0700</bug_when>
    <thetext>The website might be using https://github.com/mo/abortcontroller-polyfill.
The website would probably need to update their polyfill.
I guess a quirk is the way to go here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1550602</commentid>
    <comment_count>2</comment_count>
      <attachid>373559</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2019-07-05 20:02:18 -0700</bug_when>
    <thetext>Created attachment 373559
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1550603</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-07-05 20:02:45 -0700</bug_when>
    <thetext>&lt;rdar://problem/52712158&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1550614</commentid>
    <comment_count>4</comment_count>
      <attachid>373559</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-07-05 22:37:42 -0700</bug_when>
    <thetext>Comment on attachment 373559
Patch

Clearing flags on attachment: 373559

Committed r247191: &lt;https://trac.webkit.org/changeset/247191&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1550615</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-07-05 22:37:44 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>373559</attachid>
            <date>2019-07-05 20:02:18 -0700</date>
            <delta_ts>2019-07-05 22:37:42 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-199540-20190705200218.patch</filename>
            <type>text/plain</type>
            <size>1553</size>
            <attacher name="youenn fablet">youennf</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjQ3MDczCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOTRiNTY3M2IxZDgxOGIw
ZGNjNDllZDlhMTZhZGIxZmMwMWYwNTgwNS4uODQ4Yzg5YTQwMTFjM2QyMDE2MjJkYWNjZjUwM2Fk
OWJlN2FkZTNmMCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE1IEBACisyMDE5LTA3LTA1ICBZb3Vl
bm4gRmFibGV0ICA8eW91ZW5uQGFwcGxlLmNvbT4KKworICAgICAgICBDYXJ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