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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26544</bug_id>
          
          <creation_ts>2014-08-08 14:29:33 +0000</creation_ts>
          <short_desc>Pushing a script settings object during structured clone.</short_desc>
          <delta_ts>2014-09-16 17:48:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Bob Owen">bobowencode</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bobbyholley</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>110040</commentid>
    <comment_count>0</comment_count>
    <who name="Bob Owen">bobowencode</who>
    <bug_when>2014-08-08 14:29:33 +0000</bug_when>
    <thetext>While implementing some of the script settings object pushing for Gecko, we were wondering if Step 8 of [1] ought to have something like:
&quot;prepare to run a callback with the script settings object associated with input&quot;

added to it before it runs its sub-steps and then something like:
&quot;clean up after running a callback&quot;&quot;

after they&apos;ve finished.
This would mean that if we end up running scripts in any getters we would be sure to use the correct script settings object.

[1] http://www.whatwg.org/specs/web-apps/current-work/#internal-structured-cloning-algorithm</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110046</commentid>
    <comment_count>1</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2014-08-09 03:36:03 +0000</bug_when>
    <thetext>To give a bit more detail - it may be possible to prove from the current spec that the structured clone algorithm is always triggered when there is already script (with a script settings object) on the stack. But it would be much more robust, both from a spec and implementation standpoint, to just define the entry point in terms of the object being cloned, which removes the edge cases and ambiguity.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110250</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-18 20:35:41 +0000</bug_when>
    <thetext>The way I&apos;m currently working around this is that I preemptively clone stuff the first time I get it, then clone the result again later. The second clone can never call script. This is critical anyway because otherwise you are holding a reference to author data which could be changed arbitrarily later.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111556</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-15 22:40:48 +0000</bug_when>
    <thetext>bholly, bob: given the problem that would come up if we ever cloned something later, rather than immediately, it&apos;ll always be a spec bug if that happens. Given that, what do you think I should do here? Having the spec be more &quot;robust&quot; would really only mean that we wouldn&apos;t notice that it was badly buggy, no?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111584</commentid>
    <comment_count>4</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2014-09-16 10:29:08 +0000</bug_when>
    <thetext>Yeah sorry for the delay here. I&apos;ve been mulling it over in my (very infrequent) spare cycles.

Comment 2 is sort of orthogonal to what I was concerned about here. I&apos;m talking about the cases where the structured clone is initiated with no Script Settings Object active. Stuff like postMessage.bind used to be a problem, but we&apos;ve now fixed that with the WebIDL callback incumbent script stuff. I also had vague uneasiness about other avenues (say, if there was ever a declarative way to trigger a structured clone), but I think for now all the use cases are covered.

So I&apos;m fine to close this bug, and modify the Gecko implementation to simply assert that there&apos;s already a script settings object on the stack and use that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111608</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-16 17:48:37 +0000</bug_when>
    <thetext>Ok.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>