307 lines
10 KiB
HTML
307 lines
10 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
"http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>doh.robot Editor Miscellaneous Tests</title>
|
|
|
|
<style>
|
|
@import "../../../../util/doh/robot/robot.css";
|
|
</style>
|
|
|
|
<!-- required: dojo.js -->
|
|
<script type="text/javascript" src="../../../../dojo/dojo.js"></script>
|
|
|
|
<!-- functions to help test -->
|
|
<script type="text/javascript" src="../../helpers.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
dojo.require("dojo.DeferredList");
|
|
dojo.require("dojo.window");
|
|
dojo.require("dijit.robotx");
|
|
|
|
dojo.ready(function(){
|
|
doh.robot.initRobot('../test_Editor.html');
|
|
var editor0;
|
|
var height;
|
|
var value;
|
|
var editor1;
|
|
var editor1OrigionalBackgroundColor;
|
|
doh.register("Miscellaneous_tests", [
|
|
{
|
|
name: "wait for editors to load",
|
|
timeout: 5000,
|
|
runTest: function(){
|
|
return new dojo.DeferredList(
|
|
dijit.registry.filter(function(w){ return w.onLoadDeferred; }).map(function(w){ return w.onLoadDeferred; })
|
|
);
|
|
}
|
|
},
|
|
{
|
|
name: "addStylesheet",
|
|
timeout: 3000,
|
|
setUp: function(){
|
|
editor1 = dijit.byId("editor1");
|
|
editor1.setValue("<h1>header one</h1>");
|
|
var editorTextNode = editor1.editNode.firstChild;
|
|
editor1OrigionalBackgroundColor = dojo.getComputedStyle(editorTextNode).backgroundColor;
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
dojo.window.scrollIntoView(editor1.domNode);
|
|
editor1.addStyleSheet('test_editor.css');
|
|
|
|
setTimeout(d.getTestCallback(function(){
|
|
var editorTextNode = editor1.editNode.firstChild;
|
|
var backgroundColor = dojo.getComputedStyle(editorTextNode).backgroundColor;
|
|
var borderStyle = dojo.getComputedStyle(editorTextNode).borderBottomStyle;
|
|
var borderWidth = dojo.getComputedStyle(editorTextNode).borderBottomWidth;
|
|
doh.is("header one", editorTextNode.innerHTML);
|
|
doh.t(backgroundColor==="rgb(255, 0, 0)" || backgroundColor==="red" || backgroundColor==="#ff0000", "backgroundColor " + backgroundColor);
|
|
doh.is("solid", borderStyle);
|
|
doh.is("1px", borderWidth);
|
|
}), 1000);
|
|
|
|
return d;
|
|
}
|
|
},
|
|
{
|
|
name: "removeStylesheet",
|
|
timeout: 3000,
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
editor1.removeStyleSheet('test_editor.css');
|
|
|
|
setTimeout(d.getTestCallback(function(){
|
|
var editorNodeText = editor1.editNode.firstChild;
|
|
var backgroundColor = dojo.getComputedStyle(editorNodeText).backgroundColor;
|
|
doh.is("header one", editorNodeText.innerHTML);
|
|
doh.is(editor1OrigionalBackgroundColor, backgroundColor, "backgroundColor");
|
|
}), 1000);
|
|
|
|
return d;
|
|
}
|
|
},
|
|
{
|
|
name: "Test AutoExpanding Edtor",
|
|
timeout: 20000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("thud");
|
|
height = dojo.style(editor0.domNode, "height");
|
|
value = editor0.get("value");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
doh.robot.mouseMoveAt(editor0.iframe, 500, null, 10, 10);
|
|
doh.robot.mouseClick({left:true}, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.keyPress(dojo.keys.ENTER, 500);
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
//Now check the state!
|
|
var newHeight = dojo.style(editor0.domNode, "height");
|
|
doh.t(height < newHeight, "height decreased from " + height + " to " + newHeight);
|
|
}), 1000);
|
|
|
|
return d;
|
|
},
|
|
tearDown: function(){
|
|
if(editor0){editor0.set("value", value);}
|
|
}
|
|
},
|
|
{
|
|
name: "Test font-size style migrated to editor body",
|
|
runTest: function(){
|
|
editor0 = dijit.byId("fontSizedEditor");
|
|
var bStyle = editor0.document.body.style["fontSize"];
|
|
doh.t(bStyle != null, "bStyle set");
|
|
doh.is("30pt", bStyle.toLowerCase());
|
|
}
|
|
},
|
|
{
|
|
name: "Test prefilters do process initial content",
|
|
timeout: 20000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("filteredEditor");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
doh.robot.mouseMoveAt(editor0.iframe, 500, null, 10, 10);
|
|
doh.robot.mouseClick({left:true}, 500);
|
|
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
//Now check the state!
|
|
var val = editor0.get("value");
|
|
doh.t(val.indexOf("DOJO") >= 0, "dojo in val " + val);
|
|
doh.t(val.indexOf("notdojo") < 0, "notdojo not in val " + val);
|
|
}), 500);
|
|
|
|
return d;
|
|
}
|
|
},
|
|
{
|
|
name: "Test placeCurorAtStart (br tag) moves input before br, not inside.",
|
|
timeout: 20000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("brEditor");
|
|
value = editor0.get("value");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
doh.robot.mouseMoveAt(editor0.iframe, 500, null, 10, 10);
|
|
doh.robot.mouseClick({left:true}, 500);
|
|
doh.robot.sequence(d.getTestErrback(function(){
|
|
editor0.placeCursorAtStart();
|
|
}), 500);
|
|
doh.robot.typeKeys("abc", 500);
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
//Now check the state!
|
|
var content = editor0.get("value").replace(/[\s]/g, "");
|
|
doh.t(content.indexOf("abc<br") >= 0, "looked for 'abc<br', found: " + content);
|
|
}), 1000);
|
|
|
|
return d;
|
|
},
|
|
tearDown: function(){
|
|
if(editor0){editor0.set("value", value);}
|
|
}
|
|
},
|
|
{
|
|
name: "Test custom editor content (programmatic creation).",
|
|
timeout: 20000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("programmatic3");
|
|
value = editor0.get("value");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
doh.robot.mouseMoveAt(editor0.iframe, 500, null, 10, 10);
|
|
doh.robot.mouseClick({left:true}, 500);
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
//Now check the state!
|
|
var content = editor0.get("value");
|
|
doh.t(content.indexOf("Custom Initial Content.") >= 0);
|
|
}), 1000);
|
|
|
|
return d;
|
|
},
|
|
tearDown: function(){
|
|
if(editor0){editor0.set("value", value);}
|
|
}
|
|
},
|
|
{
|
|
name: "Verify custom filters passed in constructor are not lost",
|
|
timeout: 20000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("programmatic4");
|
|
value = editor0.get("value");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
doh.robot.mouseMoveAt(editor0.iframe, 500, null, 10, 10);
|
|
doh.robot.mouseClick({left:true}, 500);
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
//Now check the state!
|
|
doh.t(editor0.contentPreFilters.length > 1);
|
|
}), 1000);
|
|
|
|
return d;
|
|
},
|
|
tearDown: function(){
|
|
if(editor0){editor0.set("value", value);}
|
|
}
|
|
},
|
|
{
|
|
name: "Test replaceValue.",
|
|
timeout: 20000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("programmatic4");
|
|
value = editor0.get("value");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
dojo.style(editor0.domNode, "display", "none");
|
|
editor0.replaceValue("New Value");
|
|
dojo.style(editor0.domNode, "display", "none");
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
//Now check the state!
|
|
dojo.style(editor0.domNode, "display", "");
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
var newValue = editor0.get("value");
|
|
editor0.undo();
|
|
var curValue = editor0.get("value");
|
|
doh.t(newValue.indexOf(value) < 0, "Verifying content changed with no trace of old content.");
|
|
doh.t(curValue != newValue, "Verify that undo undid the change.");
|
|
doh.t(curValue == value, "Verify original value was restored.");
|
|
}), 1000);
|
|
|
|
return d;
|
|
},
|
|
tearDown: function(){
|
|
if(editor0){editor0.set("value", value);}
|
|
}
|
|
},
|
|
{
|
|
name: "Test page up/down.",
|
|
timeout: 4000,
|
|
setUp: function(){
|
|
editor0 = dijit.byId("editor0");
|
|
value = editor0.get("value");
|
|
},
|
|
runTest: function(){
|
|
var d = new doh.Deferred();
|
|
|
|
//Focus on the editor window
|
|
dojo.window.scrollIntoView(editor0.domNode);
|
|
doh.robot.sequence(d.getTestErrback(function(){
|
|
editor0.focus();
|
|
}), 500);
|
|
|
|
doh.robot.keyPress(dojo.keys.PAGE_UP, 500);
|
|
doh.robot.typeKeys("abc", 500);
|
|
doh.robot.keyPress(dojo.keys.PAGE_DOWN, 500);
|
|
doh.robot.typeKeys("def", 500);
|
|
|
|
doh.robot.sequence(d.getTestCallback(function(){
|
|
var value = editor0.get("value");
|
|
if(!dojo.isWebKit){ // commented out due to #14193
|
|
doh.t(value.indexOf("abcdef") == 0, "editor value = " + value);
|
|
}
|
|
}), 500);
|
|
|
|
return d;
|
|
},
|
|
tearDown: function(){
|
|
if(editor0){editor0.set("value", value);}
|
|
}
|
|
}
|
|
]);
|
|
doh.run();
|
|
});
|
|
</script>
|
|
</head>
|
|
</html>
|