-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue 109 plus tests for rangy.features
- Loading branch information
Showing
4 changed files
with
110 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Rangy - TextRange-to-Range Performace Tests</title> | ||
|
||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | ||
<script type="text/javascript" src="../lib/log4javascript.js"></script> | ||
<script type="text/javascript" src="../lib/jshashtable.js"></script> | ||
<script type="text/javascript" src="xntest.js"></script> | ||
<script type="text/javascript" src="testutils.js"></script> | ||
<script type="text/javascript"> | ||
xn.test.enableStackTraces = true; | ||
</script> | ||
<script type="text/javascript"> | ||
var appender = new log4javascript.InPageAppender(); | ||
//log4javascript.getRootLogger().addAppender(appender); | ||
var log = log4javascript.getRootLogger(); | ||
log4javascript.setShowStackTraces(true); | ||
|
||
</script> | ||
<script type="text/javascript"> | ||
//log4javascript.setEnabled(false); | ||
</script> | ||
<script type="text/javascript" src="../src/js/core/core.js"></script> | ||
<script type="text/javascript" src="../src/js/core/dom.js"></script> | ||
<script type="text/javascript" src="../src/js/core/domrange.js"></script> | ||
<script type="text/javascript" src="../src/js/core/wrappedrange.js"></script> | ||
<script type="text/javascript" src="../src/js/core/wrappedselection.js"></script> | ||
<script type="text/javascript" src="featuretests.js"></script> | ||
<link rel="stylesheet" type="text/css" href="tests.css"/> | ||
</head> | ||
<body> | ||
<div id="test"></div> | ||
<div id="messages"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
xn.test.suite("Browser feature tests", function(s) { | ||
rangy.init(); | ||
|
||
// Detect browser version roughly. It doesn't matter too much: these are only rough tests designed to test whether | ||
// Rangy's feature detection is hopelessly wrong | ||
|
||
|
||
var browser = jQuery.browser; | ||
var isIe = !!browser.msie; | ||
var isMozilla = !!browser.mozilla; | ||
var isOpera = !!browser.opera; | ||
var version = parseFloat(browser.version); | ||
|
||
s.test("DOM Range support", function(t) { | ||
t.assertEquals(rangy.features.implementsDomRange, !isIe || version >= 9); | ||
}); | ||
|
||
s.test("TextRange support", function(t) { | ||
t.assertEquals(rangy.features.implementsTextRange, isIe && version >= 4); | ||
}); | ||
|
||
s.test("document.selection support", function(t) { | ||
t.assertEquals(rangy.features.implementsTextRange, isIe && version >= 4); | ||
}); | ||
|
||
s.test("window.getSelection() support", function(t) { | ||
t.assertEquals(rangy.features.implementsWinGetSelection, !isIe || version >= 9); | ||
}); | ||
|
||
s.test("selection has rangeCount", function(t) { | ||
t.assertEquals(rangy.features.selectionHasRangeCount, !isIe || version >= 9); | ||
}); | ||
|
||
s.test("selection has anchor and focus support", function(t) { | ||
t.assertEquals(rangy.features.selectionHasAnchorAndFocus, !isIe || version >= 9); | ||
}); | ||
|
||
s.test("selection has extend() method", function(t) { | ||
t.assertEquals(rangy.features.selectionHasExtend, !isIe); | ||
}); | ||
|
||
s.test("HTML parsing", function(t) { | ||
t.assertEquals(rangy.features.htmlParsingConforms, !isIe); | ||
}); | ||
|
||
s.test("Multiple ranges per selection support", function(t) { | ||
t.assertEquals(rangy.features.selectionSupportsMultipleRanges, isMozilla); | ||
}); | ||
|
||
s.test("Collapsed non-editable selections support", function(t) { | ||
t.assertEquals(rangy.features.collapsedNonEditableSelectionsSupported, !isOpera); | ||
}); | ||
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters