forked from timdown/rangy
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify wrappedselection & migrate feature.test.ts to typescript
- Loading branch information
Showing
9 changed files
with
125 additions
and
156 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
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 |
---|---|---|
@@ -1,36 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Rangy - TextRange-to-Range Performace Tests</title> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<meta name="referrer" content="no-referrer"/> | ||
<title>Rangy - Features 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="../external/log4javascript.js"></script> | ||
<script type="text/javascript" src="../external/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/core/core.js"></script> | ||
<script type="text/javascript" src="../src/core/dom.js"></script> | ||
<script type="text/javascript" src="../src/core/domrange.js"></script> | ||
<script type="text/javascript" src="../src/core/wrappedrange.js"></script> | ||
<script type="text/javascript" src="../src/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> | ||
<!-- load rangy2 here in `head` to verify that rangy2 can init without need dom ready --> | ||
<script src="../../dist/core/bundles/index.umd.js"></script> | ||
<script src="../../node_modules/qunit/qunit/qunit.js"></script> | ||
<link rel="stylesheet" href="../../node_modules/qunit/qunit/qunit.css"> | ||
<script src="../qunit-ex.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="feature.test.js"></script> | ||
</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 |
---|---|---|
@@ -1,53 +1,52 @@ | ||
xn.test.suite("Browser feature tests", function(s) { | ||
rangy.init(); | ||
import Bowser from "bowser"; | ||
|
||
const browser = Bowser.getParser(window.navigator.userAgent); | ||
QUnit.module("Browser feature tests"); | ||
|
||
// 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 | ||
|
||
const isIe = browser.satisfies({ie: '>0'}); | ||
const isMozilla = browser.isEngine('gecko'); | ||
const isOpera = browser.isEngine('presto'); | ||
|
||
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); | ||
QUnit.test("DOM Range support", function(t) { | ||
t.equal(rangy.features.implementsDomRange, !browser.satisfies({ie: '<9'})); | ||
}); | ||
|
||
s.test("TextRange support", function(t) { | ||
t.assertEquals(rangy.features.implementsTextRange, isIe && version >= 4); | ||
QUnit.test("TextRange support", function(t) { | ||
t.equal(false, !!undefined); | ||
t.equal(rangy.features.implementsTextRange, !!browser.satisfies({ie: '>=4'})); | ||
}); | ||
|
||
s.test("document.selection support", function(t) { | ||
t.assertEquals(rangy.features.implementsTextRange, isIe && version >= 4); | ||
QUnit.test("document.selection support", function(t) { | ||
t.equal(rangy.features.implementsTextRange, !!browser.satisfies({ie: '>=4'})); | ||
}); | ||
|
||
s.test("window.getSelection() support", function(t) { | ||
t.assertEquals(rangy.features.implementsWinGetSelection, !isIe || version >= 9); | ||
QUnit.test("window.getSelection() support", function(t) { | ||
t.equal(rangy.features.implementsWinGetSelection, !browser.satisfies({ie: '<9'})); | ||
}); | ||
|
||
s.test("selection has rangeCount", function(t) { | ||
t.assertEquals(rangy.features.selectionHasRangeCount, !isIe || version >= 9); | ||
QUnit.test("selection has rangeCount", function(t) { | ||
t.equal(rangy.features.selectionHasRangeCount, !browser.satisfies({ie: '<9'})); | ||
}); | ||
|
||
s.test("selection has anchor and focus support", function(t) { | ||
t.assertEquals(rangy.features.selectionHasAnchorAndFocus, !isIe || version >= 9); | ||
QUnit.test("selection has anchor and focus support", function(t) { | ||
t.equal(rangy.features.selectionHasAnchorAndFocus, !browser.satisfies({ie: '<9'})); | ||
}); | ||
|
||
s.test("selection has extend() method", function(t) { | ||
t.assertEquals(rangy.features.selectionHasExtend, !isIe); | ||
QUnit.test("selection has extend() method", function(t) { | ||
t.equal(rangy.features.selectionHasExtend, !isIe); | ||
}); | ||
|
||
s.test("HTML parsing", function(t) { | ||
t.assertEquals(rangy.features.htmlParsingConforms, !isIe); | ||
QUnit.test("HTML parsing", function(t) { | ||
t.equal(rangy.features.htmlParsingConforms, !isIe); | ||
}); | ||
|
||
s.test("Multiple ranges per selection support", function(t) { | ||
t.assertEquals(rangy.features.selectionSupportsMultipleRanges, isMozilla); | ||
QUnit.test("Multiple ranges per selection support", function(t) { | ||
t.equal(rangy.features.selectionSupportsMultipleRanges, isMozilla); | ||
}); | ||
|
||
s.test("Collapsed non-editable selections support", function(t) { | ||
t.assertEquals(rangy.features.collapsedNonEditableSelectionsSupported, !isOpera); | ||
QUnit.test("Collapsed non-editable selections support", function(t) { | ||
t.equal(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
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
Oops, something went wrong.