can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
64 lines (61 loc) • 2.04 kB
HTML
<html>
<head>
<title>testing Core _docScroll function</title>
<script type="text/javascript" src="../../dojo.js" data-dojo-config="isDebug:true"></script>
<script type="text/javascript">
require(["dojo", "doh", "dojo/domReady!"], function(dojo, doh){
doh.register("t",
[
function testNonScrolled(t){
dojo.global.scrollTo(0,0);
var s = dojo._docScroll();
t.is(0, s.x);
t.is(0, s.y);
},
function testScrolled(t){
dojo.global.scrollTo(1,2);
var s = dojo._docScroll();
t.is(1, s.x);
t.is(2, s.y);
},
function testQuirksNonScrolled(t){
var win = dojo.byId('iframe').iframeContentWindow;
win.scrollTo(0,0);
var s = dojo.withGlobal(win, "_docScroll", dojo);
t.is(0, s.x);
t.is(0, s.y);
var s = dojo._docScroll();
t.is(1, s.x);
t.is(2, s.y);
},
function testQuirksScrolled(t){
dojo.global.scrollTo(0,0);
var win = dojo.byId('iframe').iframeContentWindow;
win.scrollTo(10,20);
var s = dojo.withGlobal(win, "_docScroll", dojo);
t.is(10, s.x);
t.is(20, s.y);
}
]
);
doh.runOnLoad();
});
</script>
</head>
<body>
<h1>testing Core _docScroll function</h1>
<div id='div' style="border:0px;padding:0px;margin:0px;">
<iframe id="iframe" src="javascript:'<html><head><script>frameElement.iframeContentWindow=window</script></head><body><div style=\'height:500px;width:500px;\'> </div></body>'"></iframe>
</div>
<script type="text/javascript">
// make sure div is too big to display
require(["dojo"], function(dojo) {
var div = dojo.byId('div');
div.style.height = (dojo.doc.documentElement.clientHeight + 2) + "px";
div.style.width = (dojo.doc.documentElement.clientWidth + 1) + "px";
});
</script>
</body>
</html>