dijit
Version:
Dijit provides a complete collection of user interface controls based on Dojo, giving you the power to create web applications that are highly optimized for usability, performance, internationalization, accessibility, but above all deliver an incredible u
127 lines (110 loc) • 3.52 kB
HTML
<html>
<head>
<title>doh.robot Editor/Back Button Restore Test</title>
<style>
@import "../../../../util/doh/robot/robot.css";
</style>
<script type="text/javascript" src="../../../../dojo/dojo.js"></script>
<script type="text/javascript">
require([
"doh/runner", "dojo/dom", "dojo/keys", "dojo/query", "dojo/robotx", "dijit/tests/helpers", "dojo/domReady!"
], function(doh, dom, keys, query, robot, helpers){
// This page tests that the editor's value won't be lost if the user
// accidentally navigates to a different page, and then returns to the
// page w/the editor by pressing the back button.
robot.initRobot('../BackForwardState.html');
var registry;
doh.register("setup", [
{
name: "wait for editors to load",
timeout: 5000,
runTest: helpers.waitForLoad
},
function setVars(){
registry = robot.window.require("dijit/registry");
}
]);
doh.register("back button restore", [
{
name: "set editor value",
timeout: 10000,
runTest: function(){
var d = new doh.Deferred();
var editor0 = registry.byId("editor0"),
editor1 = registry.byId("editor1");
doh.is("editor0 original contents", editor0.get('value'));
doh.is("editor1 original contents", editor1.get('value'));
editor0.set('value', 'hello');
editor1.set('value', 'goodbye');
robot.sequence(d.getTestCallback(function(){
doh.is("hello", editor0.get('value'));
doh.is("goodbye", editor1.get('value'));
}), 500);
return d;
}
},
{
name: "navigate away",
timeout: 10000,
runTest: function(){
return robot.waitForPageToLoad(function(){
// On most browsers just focusing causes navigation. On safari
// need to click...
var away = dom.byId("away", robot.doc);
dom.byId("away", robot.doc).focus();
robot.keyPress(keys.ENTER, 500);
});
}
},
{
name: "confirm navigation to new page worked",
runTest: function(){
// Confirm that we successfully navigated away
doh.is("Back/forward test helper page", (query("h1", robot.doc)[0]||{}).innerHTML);
}
},
{
name: "go back to original page",
timeout: 10000,
runTest: function(){
return robot.waitForPageToLoad(function(){
// On most browsers just focusing causes navigation. On safari
// need to click...
var back = dom.byId("back", robot.doc);
back.focus();
robot.keyPress(keys.ENTER, 500);
});
}
},
{
name: "wait for editors to load again",
timeout: 5000,
runTest: helpers.waitForLoad
},
function setVarsAgain(){
registry = robot.window.require("dijit/registry");
},
{
name: "check that editor values restored",
timeout: 10000,
runTest: function(){
var d = new doh.Deferred();
robot.sequence(d.getTestCallback(function(){
var editor0 = registry.byId("editor0"),
editor1 = registry.byId("editor1");
doh.t(editor0, "editor0 found");
doh.is("hello", editor0.get('value'));
doh.t(editor1, "editor1 found");
doh.is("goodbye", editor1.get('value'));
}), 500);
return d;
}
}
]);
doh.run();
});
</script>
</head>
</html>