Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use onFrameLoaded for feature detection

  • Loading branch information...
commit 6b58671bda503172253b6453d0df4ca925658ef4 1 parent 21681c7
@josh josh authored
View
16 src/wysihat/features.js
@@ -8,14 +8,18 @@ WysiHat.BrowserFeatures = (function() {
left: '-1000px'
});
- frame.on('load', function() {
- frameDocument = frame.contentWindow || frame.contentDocument;
- if (frameDocument.document) frameDocument = frameDocument.document;
-
- if (frame.contentDocument && frame.contentDocument.defaultView)
+ frame.onFrameLoaded(function() {
+ if (typeof frame.contentDocument !== 'undefined') {
+ frameDocument = frame.contentDocument;
+ } else if (typeof frame.contentWindow !== 'undefined' && typeof frame.contentWindow.document !== 'undefined') {
+ frameDocument = frame.contentWindow.document;
+ }
+
+ if (typeof frame.contentDocument !== 'undefined' && typeof frame.contentDocument.defaultView !== 'undefined') {
frameWindow = frame.contentDocument.defaultView;
- else if (frame.contentWindow.document)
+ } else if (typeof frame.contentWindow.document !== 'undefined') {
frameWindow = frame.contentWindow;
+ }
frameDocument.designMode = 'on';
View
28 test/unit/features_test.js
@@ -1,21 +1,29 @@
new Test.Unit.Runner({
+ setup: function() {
+ WysiHat.BrowserFeatures.run();
+ },
+
testDetectParagraphType: function() {
var runner = this;
- if (Prototype.Browser.WebKit)
- runner.assertEqual("div", WysiHat.BrowserFeatures.paragraphType);
- else if (Prototype.Browser.Gecko)
- runner.assertEqual("br", WysiHat.BrowserFeatures.paragraphType);
- else if (Prototype.Browser.IE)
- runner.assertEqual("p", WysiHat.BrowserFeatures.paragraphType);
+ runner.wait(1000, function() {
+ if (Prototype.Browser.WebKit)
+ runner.assertEqual("div", WysiHat.BrowserFeatures.paragraphType);
+ else if (Prototype.Browser.Gecko)
+ runner.assertEqual("br", WysiHat.BrowserFeatures.paragraphType);
+ else if (Prototype.Browser.IE)
+ runner.assertEqual("p", WysiHat.BrowserFeatures.paragraphType);
+ });
},
testDetectIndentType: function() {
var runner = this;
- if (Prototype.Browser.WebKit || Prototype.Browser.IE)
- runner.assertEqual(true, WysiHat.BrowserFeatures.indentInsertsBlockquote);
- else if (Prototype.Browser.Gecko)
- runner.assertEqual(false, WysiHat.BrowserFeatures.indentInsertsBlockquote);
+ runner.wait(1000, function() {
+ if (Prototype.Browser.WebKit || Prototype.Browser.IE)
+ runner.assertEqual(true, WysiHat.BrowserFeatures.indentInsertsBlockquote);
+ else if (Prototype.Browser.Gecko)
+ runner.assertEqual(false, WysiHat.BrowserFeatures.indentInsertsBlockquote);
+ });
}
});
View
3  test/unit/fixtures/features.html
@@ -1,3 +0,0 @@
-<script type="text/javascript">
- WysiHat.BrowserFeatures.run();
-</script>

0 comments on commit 6b58671

Please sign in to comment.
Something went wrong with that request. Please try again.