From 9198ddbd3d1dbea12f0f20324540956d4c4ca71d Mon Sep 17 00:00:00 2001 From: Steven Parkes Date: Fri, 5 Feb 2010 15:57:42 -0800 Subject: [PATCH] tweak to make sure docs are loaded async --- src/dom/document.js | 7 +++++-- test/data.js | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dom/document.js b/src/dom/document.js index f0474ffb..af5304d5 100644 --- a/src/dom/document.js +++ b/src/dom/document.js @@ -130,8 +130,11 @@ __extend__(DOMDocument.prototype, { xhr = ({ open: function(){}, send: function(){ - this.responseText = content; - this.onreadystatechange(); + var self = this; + setTimeout(function(){ + self.responseText = content; + self.onreadystatechange(); + },0); }, status: 200 }); diff --git a/test/data.js b/test/data.js index c5c9ef61..2abe7eeb 100755 --- a/test/data.js +++ b/test/data.js @@ -6,7 +6,9 @@ url_escaped = "data:text/html,"+escape(doc); base64 = "data:text/html;base64,"+Base64.encode(doc); debug(url_escaped); window.location = "about:blank"; +Envjs.wait(); window.location = url_escaped; +Envjs.wait(); debug(window.document.documentElement.innerHTML); if(window.document.documentElement.innerHTML != inner){ debug(window.document.documentElement.innerHTML); @@ -15,13 +17,17 @@ if(window.document.documentElement.innerHTML != inner){ } debug(base64); window.location = "about:blank"; +Envjs.wait(); window.location = base64; +Envjs.wait(); debug(window.document.documentElement.innerHTML); if(window.document.documentElement.innerHTML != inner){ throw new Error("b"+window.document.documentElement.innerHTML); } window.location = "about:blank"; +Envjs.wait(); window.location = "data:,"+escape("Hello, World from a data uri!"); +Envjs.wait(); debug(window.location+""); debug(window.document.documentElement.innerHTML); inner = "Hello, World from a data uri!";