<?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>202485</bug_id>
          
          <creation_ts>2019-10-02 11:17:40 -0700</creation_ts>
          <short_desc>typeof (function that masquerades as undefined) is &quot;function&quot;, should be &quot;undefined&quot;</short_desc>
          <delta_ts>2020-12-03 09:46:19 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>215572</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Geoffrey Garen">ggaren</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>adf</cc>
    
    <cc>ap</cc>
    
    <cc>ashvayka</cc>
    
    <cc>fpizlo</cc>
    
    <cc>saam</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1576070</commentid>
    <comment_count>0</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2019-10-02 11:17:40 -0700</bug_when>
    <thetext>See https://bugs.webkit.org/show_bug.cgi?id=198805.

The openDatabase function is allocated by calling JSFunction::createFunctionThatMasqueradesAsUndefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1576071</commentid>
    <comment_count>1</comment_count>
      <attachid>380040</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2019-10-02 11:19:35 -0700</bug_when>
    <thetext>Created attachment 380040
test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1577081</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-10-04 17:07:39 -0700</bug_when>
    <thetext>The test case produces PASS for me in Safari 13.0.1.

PASS: typeof window.openDatabase is undefined</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1579031</commentid>
    <comment_count>3</comment_count>
    <who name="Oz">adf</who>
    <bug_when>2019-10-11 01:47:31 -0700</bug_when>
    <thetext>I believe the issue is that (were these both tests)

PASS: typeof window.openDatabase is undefined
PASS: typeof window.openDatabase is function

Both can&apos;t be true.

Specifically

window.openDatabase == &quot;function&quot; is true
window.openDatabase == &quot;undefined&quot; is also true

http://locutus.sorcerer.co.uk/demo/safari-openDatabase.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711701</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2020-12-03 09:46:19 -0800</bug_when>
    <thetext>(In reply to Oz from comment #3)
&gt; PASS: typeof window.openDatabase is undefined
&gt; PASS: typeof window.openDatabase is function
&gt; 
&gt; Both can&apos;t be true.

Nicely noted, thank you.

That discrepancy was made possible due to peephole optimization in BytecodeGenerator::emitEqualityOpImpl(), which detects patterns like `typeof X === &quot;Y&quot;` and emits different bytecodes depending on Y.
r265907 fixed the `typeof X === &quot;function&quot;` bytecode op to return `false` for masquerader (aka [[IsHTMLDDA]]) objects.

test262 coverage was added in https://github.com/tc39/test262/pull/2706.

*** This bug has been marked as a duplicate of bug 215572 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>380040</attachid>
            <date>2019-10-02 11:19:35 -0700</date>
            <delta_ts>2019-10-02 11:19:35 -0700</delta_ts>
            <desc>test case</desc>
            <filename>scratch.html</filename>
            <type>text/html</type>
            <size>313</size>
            <attacher name="Geoffrey Garen">ggaren</attacher>
            
              <data encoding="base64">PHByZSBpZD0iY29uc29sZSI+PC9wcmU+Cgo8c2NyaXB0PgpsZXQgbG9nID0gZnVuY3Rpb24ocykK
ewoJZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImNvbnNvbGUiKS5hcHBlbmRDaGlsZChkb2N1bWVu
dC5jcmVhdGVUZXh0Tm9kZShzICsgIlxuIikpOwp9OwoKbGV0IHJlc3VsdCA9IHR5cGVvZiB3aW5k
b3cub3BlbkRhdGFiYXNlOwpsZXQgcHJlZml4ID0gcmVzdWx0ID09ICJ1bmRlZmluZWQiID8gIlBB
U1M6ICIgOiAiRkFJTDogIgoKbG9nKHByZWZpeCArICJ0eXBlb2Ygd2luZG93Lm9wZW5EYXRhYmFz
ZSBpcyAiICsgcmVzdWx0KTsKPC9zY3JpcHQ+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>