<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Handle IDLPromise&lt;&gt; properly"
   href="https://bugs.webkit.org/show_bug.cgi?id=166752#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Handle IDLPromise&lt;&gt; properly"
   href="https://bugs.webkit.org/show_bug.cgi?id=166752">bug 166752</a>
              from <span class="vcard"><a class="email" href="mailto:sam&#64;webkit.org" title="Sam Weinig &lt;sam&#64;webkit.org&gt;"> <span class="fn">Sam Weinig</span></a>
</span></b>
        <pre>Any thoughts on a design for this, I have been struggling a bit. 

The biggest issue is that unlike all other types, the way our promise code works, you always have to pass a JSDOMGlobalObject and an ExecState to any function that might want to create a promise. Ideally, what we would do would be to have a new type that can be instantiated without a JSDOMGlobalObject and an ExecState, that gets wrapped by the JS promise once it enters the bindings. e.g.

Ref&lt;NonJSPromise&gt; MyClass::load()
{
    ...

    m_promise = NonJSPromise::create();

    ...

    return m_promise.releaseNonNull();
}

And then the bindings layer does something that creates a JSPromiseDeferred from the NonJSPromise, but I am not clear on how the lifetime of the JSPromiseDeferred would be managed. Perhaps the NonJSPromise (now even more poorly named) could act as a lazy WebCore::DeferredPromise, and fill in the JSPromiseDeferred and JSDOMGlobalObject when it gets passed into the bindings layer?

Anyway, maybe you have a better design in mind.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>