<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Class: Puppeteer::ExecutionContext::JavaScriptFunction
  
    &mdash; Documentation by YARD 0.9.24
  
</title>

  <link rel="stylesheet" href="../../css/style.css" type="text/css" />

  <link rel="stylesheet" href="../../css/common.css" type="text/css" />

<script type="text/javascript">
  pathId = "Puppeteer::ExecutionContext::JavaScriptFunction";
  relpath = '../../';
</script>


  <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>


  </head>
  <body>
    <div class="nav_wrap">
      <iframe id="nav" src="../../class_list.html?1"></iframe>
      <div id="resizer"></div>
    </div>

    <div id="main" tabindex="-1">
      <div id="header">
        <div id="menu">
  
    <a href="../../_index.html">Index (J)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../Puppeteer.html" title="Puppeteer (class)">Puppeteer</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ExecutionContext.html" title="Puppeteer::ExecutionContext (class)">ExecutionContext</a></span></span>
     &raquo; 
    <span class="title">JavaScriptFunction</span>
  
</div>

        <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../../class_list.html">

        <svg width="24" height="24">
          <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
        </svg>
    </a>
  
</div>
        <div class="clear"></div>
      </div>

      <div id="content"><h1>Class: Puppeteer::ExecutionContext::JavaScriptFunction
  
  
  
</h1>
<div class="box_info">
  
  <dl>
    <dt>Inherits:</dt>
    <dd>
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Puppeteer::ExecutionContext::JavaScriptFunction</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
    </dd>
  </dl>
  

  
  
  
  
  <dl>
      <dt>Includes:</dt>
      <dd><span class='object_link'><a href="../IfPresent.html" title="Puppeteer::IfPresent (module)">IfPresent</a></span></dd>
  </dl>
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/puppeteer/execution_context.rb</dd>
  </dl>
  
</div>








  
    <h2>
      Instance Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#evaluate_with-instance_method" title="#evaluate_with (instance method)">#<strong>evaluate_with</strong>(client:, context_id:)  &#x21d2; Object|JSHandle </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(execution_context, expression, args, return_by_value)  &#x21d2; JavaScriptFunction </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>A new instance of JavaScriptFunction.</p>
</div></span>
  
</li>

      
    </ul>
  


  
  
  
  
  
  
  
  
  <h3 class="inherited">Methods included from <span class='object_link'><a href="../IfPresent.html" title="Puppeteer::IfPresent (module)">IfPresent</a></span></h3>
  <p class="inherited"><span class='object_link'><a href="../IfPresent.html#if_present-instance_method" title="Puppeteer::IfPresent#if_present (method)">#if_present</a></span></p>
<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    #<strong>initialize</strong>(execution_context, expression, args, return_by_value)  &#x21d2; <tt><span class='object_link'><a href="" title="Puppeteer::ExecutionContext::JavaScriptFunction (class)">JavaScriptFunction</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Returns a new instance of JavaScriptFunction.</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


95
96
97
98
99
100</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/puppeteer/execution_context.rb', line 95</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_execution_context'>execution_context</span><span class='comma'>,</span> <span class='id identifier rubyid_expression'>expression</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_return_by_value'>return_by_value</span><span class='rparen'>)</span>
  <span class='ivar'>@execution_context</span> <span class='op'>=</span> <span class='id identifier rubyid_execution_context'>execution_context</span>
  <span class='ivar'>@expression</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span>
  <span class='ivar'>@return_by_value</span> <span class='op'>=</span> <span class='id identifier rubyid_return_by_value'>return_by_value</span>
  <span class='ivar'>@args</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="evaluate_with-instance_method">
  
    #<strong>evaluate_with</strong>(client:, context_id:)  &#x21d2; <tt>Object|<span class='object_link'><a href="../JSHandle.html" title="Puppeteer::JSHandle (class)">JSHandle</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>client</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../CDPSession.html" title="Puppeteer::CDPSession (class)">Puppeteer::CDPSession</a></span></tt>)</span>
      
      
      
    </li>
  
    <li>
      
        <span class='name'>context_id</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Object|<span class='object_link'><a href="../JSHandle.html" title="Puppeteer::JSHandle (class)">JSHandle</a></span></tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/puppeteer/execution_context.rb', line 105</span>

<span class='kw'>def</span> <span class='id identifier rubyid_evaluate_with'>evaluate_with</span><span class='lparen'>(</span><span class='label'>client:</span><span class='comma'>,</span> <span class='label'>context_id:</span><span class='rparen'>)</span>
  <span class='comment'># `function` can be omitted in JS after ES2015.
</span>  <span class='comment'># https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Object_initializer
</span>  <span class='comment'>#
</span>  <span class='comment'># Original puppeteer implementation take it into consideration.
</span>  <span class='comment'># But we don&#39;t support the syntax here.
</span>
  <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_send_message'>send_message</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Runtime.callFunctionOn</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
    <span class='label'>functionDeclaration:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@expression</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_suffix'>suffix</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
    <span class='label'>executionContextId:</span> <span class='id identifier rubyid_context_id'>context_id</span><span class='comma'>,</span>
    <span class='label'>arguments:</span> <span class='id identifier rubyid_converted_args'>converted_args</span><span class='comma'>,</span>
    <span class='label'>returnByValue:</span> <span class='ivar'>@return_by_value</span><span class='comma'>,</span>
    <span class='label'>awaitPromise:</span> <span class='kw'>true</span><span class='comma'>,</span>
    <span class='label'>userGesture:</span> <span class='kw'>true</span><span class='comma'>,</span>
  <span class='rparen'>)</span> <span class='comment'># .catch(rewriteError);
</span>
  <span class='id identifier rubyid_exception_details'>exception_details</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>exceptionDetails</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_remote_object'>remote_object</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Puppeteer.html" title="Puppeteer (class)">Puppeteer</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../RemoteObject.html" title="Puppeteer::RemoteObject (class)">RemoteObject</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../RemoteObject.html#initialize-instance_method" title="Puppeteer::RemoteObject#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>result</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_exception_details'>exception_details</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="EvaluationError.html" title="Puppeteer::ExecutionContext::EvaluationError (class)">EvaluationError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../ExecutionContext.html#initialize-instance_method" title="Puppeteer::ExecutionContext#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Evaluation failed: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exception_details'>exception_details</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='kw'>if</span> <span class='ivar'>@return_by_value</span>
    <span class='id identifier rubyid_remote_object'>remote_object</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
  <span class='kw'>else</span>
    <span class='const'><span class='object_link'><a href="../../Puppeteer.html" title="Puppeteer (class)">Puppeteer</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../JSHandle.html" title="Puppeteer::JSHandle (class)">JSHandle</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'><span class='object_link'><a href="../JSHandle.html#create-class_method" title="Puppeteer::JSHandle.create (method)">create</a></span></span><span class='lparen'>(</span>
      <span class='label'>context:</span> <span class='ivar'>@execution_context</span><span class='comma'>,</span>
      <span class='label'>remote_object:</span> <span class='id identifier rubyid_remote_object'>remote_object</span><span class='comma'>,</span>
    <span class='rparen'>)</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Fri Jun 12 12:38:35 2020 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.9.24 (ruby-2.6.3).
</div>

    </div>
  </body>
</html>