Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ran this page in various browsers (Safari, Opera, IE7-9, Chrome, Firefox) and got consistent results with everything but firefox, in firefox the prototypes are sandboxed so that's good but the second test fails for some reason in firefox. The iframe prototype isn't immediately augmented. But this doesn't matter if you didn't mean to augment it anyway. You could try running it in more browsers to test.</p> <p>Note that this doesn't really test any of the quirks for example (<code>My.Array().slice</code> would return the main <code>window</code> arrays depending on browser...) and there could be more. So I would say it's pretty unsafe.</p> <p>It's an overkill anyway and seems too much work for no real gain.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; (function(){ var ifr = document.createElement("iframe"), callbacks = [], hasReadyState = "readyState" in ifr; ifr.style.display = "none"; document.body.appendChild(ifr); ifrDoc = ifr.contentWindow.document; ifrDoc.open(); ifrDoc.write( "&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;"+"&lt;"+"script"+"&gt;var w = this;"+"&lt;/"+"script"+"&gt;"+"&lt;/body&gt;&lt;/html&gt;"); ifrDoc.close(); if( hasReadyState ) { ifr.onreadystatechange = function(){ if( this.readyState === "complete" ) { fireCallbacks(); } }; } function fireCallbacks(){ var i, l = callbacks.length; window.My = ifr.contentWindow.w; for( i = 0; i &lt; l; ++i ) { callbacks[i](); } callbacks.length = 0; } function checkReady(){ if( hasReadyState &amp;&amp; ifr.readyState === "complete" ) { fireCallbacks(); } else if( !hasReadyState ) { fireCallbacks(); } } window.MyReady = function(fn){ if( typeof fn == "function" ) { callbacks.push( fn ); } }; window.onload = checkReady; //Change this to DOMReady or whatever })() MyReady( function(){ My.Object.prototype.test = "hi"; var a = new My.Object(), b = new Object(); console.log( Math.random(), My.Object !== Object &amp;&amp; b.test !== "hi", a.test === "hi" ); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload