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
119 lines (108 loc) • 3.18 kB
HTML
<html lang="en">
<head>
<title>Editor Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2"/>
<script type="text/javascript" src="../boilerplate.js"></script>
<script type="text/javascript">
require([
"doh/runner",
"dojo/dom",
"dojo/dom-construct",
"dojo/parser",
"dijit/registry",
"dijit/tests/helpers",
"dijit/Editor",
"dojo/domReady!"
], function(doh, dom, domConstruct, parser, registry, helpers, Editor){
doh.register("setup", [
{
name: "parse",
timeout: 5000,
runTest: function(){
parser.parse();
// In some browsers, the editor will not yet be loaded. Test that no error occurs
// when retrieving the value.
doh.is("initial content", editor.get("value"));
}
},
{
name: "wait for editors to load",
timeout: 5000,
runTest: helpers.waitForLoad
}
]);
doh.register("miscellaneous", [
{
name: "set value on unfocused editor",
runTest: function(){
editor.set("value", "hello");
editor.focus();
doh.is("hello", editor.editNode.textContent || editor.editNode.innerText);
doh.is("hello", editor.get("value"));
}
},
{
name: "get value of unloaded editor",
runTest: function(){
var tmpEditor = new Editor({ value: "test editor value"});
doh.is("test editor value", tmpEditor.get("value"));
doh.is("test editor value", tmpEditor.value);
doh.f(tmpEditor.isLoaded);
tmpEditor.startup();
doh.is("test editor value", tmpEditor.get("value"));
doh.is("test editor value", tmpEditor.value);
doh.f(tmpEditor.isLoaded);
}
}
]);
doh.register("reparent", [
{
name: "update editor's value",
runTest: function(){
var d = new doh.Deferred();
editor.set("value", "updated content");
setTimeout(function(){
d.callback();
}, 500);
return d;
}
},
{
name: "reparent",
runTest: function(){
var d = new doh.Deferred();
domConstruct.place(dom.byId("editorWrapper"), "anchorDiv", "before");
// Reparenting the editor causing another onLoad event on the iframe.
// Wait for that to complete and then check that editor's value wasn't corrupted.
setTimeout(d.getTestCallback(function(){
doh.is("updated content", editor.get("value"), "get('value')");
var realContent = editor.iframe.contentDocument.body.textContent ||
editor.iframe.contentDocument.body.innerText;
doh.is("updated content", realContent, "real content")
}), 500);
return d;
}
}
]);
doh.register("destroy", [
{
name: "destroy the editor",
runTest: function(){
// just making sure this doesn't throw an exception
editor.destroy();
}
}
]);
doh.run();
});
</script>
</head>
<body class="claro" role="main">
<div id="anchorDiv">This is the anchor div.</div>
<div id="editorWrapper">
<div data-dojo-id="editor" data-dojo-type="dijit/Editor"
data-dojo-props='"aria-label":"editor", name:"field"'>initial content</div>
</div>
</body>
</html>