widget.html revision 8590f7a396daf54f3440f970f550bbc9f59bc7b7
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf #console .yui3-console-entry {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf padding:2px;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf margin:0px;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf min-height:0;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf #console .yui3-console-entry-fail .yui3-console-entry-cat {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf background-color:red;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf #console .yui3-console-entry-pass .yui3-console-entry-cat {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf background-color:green;
0bc523e585d34fb799f65e1c4fd7d163e401a501Alan Perry #console .yui3-console-entry-perf .yui3-console-entry-cat {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf background-color:blue;
257c04ecb24858f6d68020a41589306f554ea434Marcel Telka #console .yui3-console-entry-content {
257c04ecb24858f6d68020a41589306f554ea434Marcel Telka font-family:monospace;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf #console .yui3-console-entry-cat {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf padding:0;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf height:10px;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf width:10px;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf line-height:10px;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf overflow:hidden;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf display:inline-block;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf *display:inline;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf #console {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf position:static;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf #automationmsg {
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw margin-left:2em;
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw .msg-hidden {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf display:none;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf html, body {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf height:100%;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf /** Extended Core Tests Need This. Custom CSS **/
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf .yui3-mywidget-hidden {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf display:none;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf /** SingleBox Core Tests Need This. Custom CSS **/
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf .yui3-mysingleboxwidget-hidden {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf display:none;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf /** Custom Widget Tests Need This. Custom CSS **/
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf .yui3-mycustomwidget-hidden {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf visibility:hidden;
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf <p><input type="button" value="Run Tests" id="btnRun" disabled="true"><span id="automationmsg" class="msg-hidden">Currently running tests, with logging disabled to speed up automation. Button will be enabled once complete.</span></p>
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf <div id="widgetRenderContainer" style="height:300px;width:300px"></div>
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf useBrowserConsole:false,
7a1efdfee8cbdecea34d3d866bbfb46e39b06e0apawelw filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf }).use('test', 'widget', 'node-event-simulate', 'console', function (Y) {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Extended Widget
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf function MyWidget() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf MyWidget.NAME = "myWidget";
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Single Box Widget
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf function MySingleBoxWidget() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf MySingleBoxWidget.superclass.constructor.apply(this, arguments);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf MySingleBoxWidget.NAME = "mySingleBoxWidget";
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf CONTENT_TEMPLATE:null
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var suite = new Y.Test.Suite("Widget Tests");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var coreTests = {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf name : "Widget Core Tests",
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf createWidget: function(cfg) {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf return new Y.Widget(cfg);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testInstantiation" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Basic API
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testInitState" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("div", w.get("boundingBox").get("tagName").toLowerCase());
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("div", w.get("contentBox").get("tagName").toLowerCase());
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("disabled"), "disabled should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("focused"), "focused should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame("", w.get("height"), "height should be empty string");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame("", w.get("width"), "width should be empty string");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isString(w.get("id"), "id should be a string");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("initialized"), "initialized should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("destroyed"), "destroyed should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("rendered"), "rendered should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("visible"), "visible should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isNull(w.get("tabIndex"), "tabIndex should be null");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testNonRenderedStateUpdate" : function() {
257c04ecb24858f6d68020a41589306f554ea434Marcel Telka // WRITE ONCE
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf id: "foobar",
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("disabled", true);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("height", 100);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("width", 200);
6ed1276fb5fe78fb1cce38682748a830ef8bd157pawelw w.set("visible", false);
6ed1276fb5fe78fb1cce38682748a830ef8bd157pawelw w.set("tabIndex", 5);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("span", w.get("boundingBox").get("tagName").toLowerCase());
4360436b3c604bc28d37be269ad152b4c38157c3pawelw Y.Assert.areEqual("span", w.get("contentBox").get("tagName").toLowerCase());
4360436b3c604bc28d37be269ad152b4c38157c3pawelw Y.Assert.areEqual("bb", w.get("boundingBox").get("id"));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("disabled"), "disabled should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("focused"), "focused should be false"); // focused is READONLY
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("100", w.get("height"), "height should be 100px");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("200", w.get("width"), "width should be 200px");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("foobar", w.get("id"), "id should be foobar");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("visible"), "visible should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(5, w.get("tabIndex"), "tabIndex should be 5");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testValidationReadonlyWriteonce" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // READONLY
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("focused", true);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("rendered", true);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // WRITE ONCE
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("boundingBox", Y.Node.create("<span id='bb'></span>"));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("contentBox", Y.Node.create("<span id='cb'></span>"));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("render", true);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // INVALID
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("tabIndex", "foo");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // State should be the same as the initial state
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw Y.Assert.areEqual("div", w.get("boundingBox").get("tagName").toLowerCase());
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw Y.Assert.areEqual("div", w.get("contentBox").get("tagName").toLowerCase());
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw Y.Assert.isFalse(w.get("disabled"), "disabled should be false");
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw Y.Assert.isFalse(w.get("focused"), "focused should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame("", w.get("height"), "height should be empty string");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame("", w.get("width"), "width should be empty string");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isString(w.get("id"), "id should be a string");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("initialized"), "initialized should be true");
385470574fb49e32c324af06c01d697a16cc3c4bying tian - Beijing China Y.Assert.isFalse(w.get("destroyed"), "destroyed should be false");
f8a673ad9145b262edb65a98fb3fb92027d23a05ying tian - Beijing China Y.Assert.isFalse(w.get("rendered"), "rendered should be false");
257c04ecb24858f6d68020a41589306f554ea434Marcel Telka Y.Assert.isTrue(w.get("visible"), "visible should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isNull(w.get("tabIndex"), "tabIndex should be null");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testStaticClassNameGeneration" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("yui3-widget-foo-bar", Y.Widget.getClassName("foo", "bar"));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testInstanceClassNameGeneration" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("yui3-widget-foo-bar", w.getClassName("foo", "bar"));
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu "testCssPrefix" : function() {
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.areEqual("yui3-widget", w._cssPrefix, "Unexpected Prefix");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu "testRender" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf id: "widgetRender"
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bbFromDom = Y.Node.one("#widgetRender");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(bbFromDom), "boundingBox not found in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bbFromDom.get("firstChild").compareTo(w.get("contentBox")), "contentBox not first child of boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bbFromDom.compareTo(Y.Node.one("body").get("firstChild")), "widget not inserted to body");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("rendered"), "Rendered flag not set");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testRenderTo" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf id: "widgetRender"
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.render("#widgetRenderContainer");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bbFromDom = Y.Node.one("#widgetRender");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bbFromDom.get("parentNode").compareTo(Y.Node.one("#widgetRenderContainer")), "widget not rendered to container passed to render()");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(bbFromDom), "boundingBox not found in DOM");
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.isTrue(bbFromDom.get("firstChild").compareTo(w.get("contentBox")), "contentBox not first child of boundingBox");
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.isTrue(w.get("rendered"), "Rendered flag not set");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testBaseClassNames" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bb = w.get("boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var cb = w.get("contentBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass("yui3-widget"), "bb missing yui3-widget marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(cb.hasClass("yui3-widget-content"), "cb missing yui3-widget-content marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testHeight" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf height:100,
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf render:"#widgetRenderContainer"
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bb = w.get("boundingBox"),
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf cb = w.get("contentBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Default CSS has no border/padding/margin on BB/CB so this should be fine in all browsers
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(100, bb.get("offsetHeight"), "100 height not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(100, cb.get("offsetHeight"), "100 height not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("height", "200px");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(200, bb.get("offsetHeight"), "200px height not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(200, cb.get("offsetHeight"), "200px height not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("height", "50%");
f8a673ad9145b262edb65a98fb3fb92027d23a05ying tian - Beijing China Y.Assert.areEqual(150, bb.get("offsetHeight"), "% height not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(150, cb.get("offsetHeight"), "% height not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testWidth" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf width:100,
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf render:"#widgetRenderContainer"
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bb = w.get("boundingBox"),
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf cb = w.get("contentBox");
4360436b3c604bc28d37be269ad152b4c38157c3pawelw // Default CSS has no border/padding/margin on BB/CB so this should be fine in all browsers
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(100, bb.get("offsetWidth"), "100 width not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(100, cb.get("offsetWidth"), "100 width not set correctly in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("width", "200px");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.areEqual(200, bb.get("offsetWidth"), "200px width not set correctly in DOM");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.areEqual(200, cb.get("offsetWidth"), "200px width not set correctly in DOM");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu w.set("width", "50%");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.areEqual(150, bb.get("offsetWidth"), "% width not set correctly in DOM");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.areEqual(150, cb.get("offsetWidth"), "% width not set correctly in DOM");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu "testDisabled" : function() {
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu var w = this.createWidget({render:true});
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu var bb = w.get("boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var className = w._cssPrefix + "-disabled";
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("disabled"), "disabled should be false by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a disabled marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("disabled", true);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("disabled"), "disabled should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass(className), "bb should have a disabled marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("disabled", false);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("disabled"), "disabled should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a disabled marker class");
2038334ab26baaa43c9083f35def041511c3cc1fUnknown "testDisableEnable" : function() {
385470574fb49e32c324af06c01d697a16cc3c4bying tian - Beijing China var w = this.createWidget({render:true});
f8a673ad9145b262edb65a98fb3fb92027d23a05ying tian - Beijing China var bb = w.get("boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var className = w._cssPrefix + "-disabled";
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("disabled"), "disabled should be false by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a disabled marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("disabled"), "disabled should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass(className), "bb should have a disabled marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("disabled"), "disabled should be false");
4e54023805e14cf984b9f0041df73c16334a7a88ls Y.Assert.isFalse(bb.hasClass(className), "bb should not have a disabled marker class");
4e54023805e14cf984b9f0041df73c16334a7a88ls "testFocusBlur" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // The focused attribute is read-only, so we test through the public api
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var w = this.createWidget({render:true});
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bb = w.get("boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var className = w._cssPrefix + "-focused";
2038334ab26baaa43c9083f35def041511c3cc1fUnknown // TODO ENH REQUEST: This doesn't seem right. We should focus on render.
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("focused"), "focused should be false by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a disabled marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("focused"), "focused should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass(className), "bb should have a focused marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("focused"), "focused should be false");
4360436b3c604bc28d37be269ad152b4c38157c3pawelw Y.Assert.isFalse(bb.hasClass(className), "bb should not have a focused marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf "testTabIndex" : function() {
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var w = this.createWidget({render:true});
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var bb = w.get("boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isNull(w.get("tabIndex"), "tabIndex should be null by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.get("tabIndex") <= 0, "tabIndex should not be set by default"); // default varies across browsers 0 or -1
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame(6, w.get("tabIndex"), "tabIndex should be 6");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // FIXME: See http://yuilibrary.com/projects/yui3/ticket/2531105
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Y.Assert.areSame(6, bb.get("tabIndex"), "tabIndex should be 6");
4372d277de71fc7c19cb9f41df9b8757b34e2cc5pawelw Y.Assert.areSame("testId", bb.get("id"), "id not reflected in DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("visible"), "visible should be true by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a hidden marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areNotEqual("none", bb.getStyle("display"), "widget should not be display:none");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("visible"), "visible should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass(className), "bb should have an hidden marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("none", bb.getStyle("display"), "Default CSS should hide widget using display:none");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("visible"), "visible should be true by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a hidden marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areNotEqual("none", bb.getStyle("display"), "widget should not be display:none");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("visible"), "visible should be true by default");
4360436b3c604bc28d37be269ad152b4c38157c3pawelw Y.Assert.isFalse(bb.hasClass(className), "bb should not have a hidden marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areNotEqual("none", bb.getStyle("display"), "widget should not be display:none");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("visible"), "visible should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass(className), "bb should have an hidden marker");
7a70ede882eacbae00c8d5209afb443e7755684cpawelw Y.Assert.areEqual("none", bb.getStyle("display"), "Default CSS should hide widget using display:none");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("visible"), "visible should be true by default");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(bb.hasClass(className), "bb should not have a hidden marker class");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areNotEqual("none", bb.getStyle("display"), "widget should not be display:none");
63aa537723d4883425b44d96b6316b7ad14053fcAlan Perry Y.Assert.isTrue(w.get("boundingBox").compareTo(bb), "bb passed to constructor, not used");
63aa537723d4883425b44d96b6316b7ad14053fcAlan Perry Y.Assert.isTrue(w.get("contentBox").compareTo(bb.get("firstChild")), "Missing contentBox");
63aa537723d4883425b44d96b6316b7ad14053fcAlan Perry Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "boundingBox moved from it's place in the DOM");
63aa537723d4883425b44d96b6316b7ad14053fcAlan Perry Y.Assert.isTrue(w.get("contentBox").compareTo(cb), "cb passed to constructor, not used");
c75976d12071ddd21443266260066ba036671682pawelw Y.Assert.isTrue(w.get("boundingBox").compareTo(cb.get("parentNode")), "Missing boundingBox");
c75976d12071ddd21443266260066ba036671682pawelw Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "contentBox moved from it's place in the DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(bb), "bb passed to constructor, not used");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("contentBox").compareTo(cb), "cb passed to constructor, not used");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(cb.get("parentNode")), "bb not not cb's parent");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "bb moved from it's place in the DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").get("firstChild").compareTo(cb), "cb not bb's firstChild");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.isTrue(w.get("boundingBox").compareTo(bb), "bb passed to constructor, not used");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.isTrue(w.get("contentBox").compareTo(bb.get("firstChild")), "Missing contentBox");
2ee4dfc799525d35706ee64a901cd970a7080bb6Jane Chu Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "boundingBox moved from it's place in the DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("contentBox").compareTo(cb), "cb passed to constructor, not used");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(cb.get("parentNode")), "Missing boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "contentBox moved from it's place in the DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(bb), "bb passed to constructor, not used");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("contentBox").compareTo(cb), "cb passed to constructor, not used");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(cb.get("parentNode")), "bb not not cb's parent");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "bb moved from it's place in the DOM");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").get("firstChild").compareTo(cb), "cb not bb's firstChild");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf container.append("<div id='srcNode'><div id='foo'></div></div>");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("contentBox").compareTo(sn), "srcNode should end up being cb");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("srcNode").compareTo(sn), "srcNode should still be accessible from srcNode attribute");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(sn.get("parentNode")), "Missing boundingBox");
4360436b3c604bc28d37be269ad152b4c38157c3pawelw Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "srcNode moved from it's place in the DOM");
4360436b3c604bc28d37be269ad152b4c38157c3pawelw Y.Assert.isNotNull(w.get("contentBox").one("#foo"), "contents of srcNode not maintained");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf ocb.append("<div><div id='outerContent'>Outer</div></div>");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf icb.append("<div><div id='innerContent'>Inner</div></div>");
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.areSame(o, Y.Widget.getByNode(outerContent), "Couldn't find outer widget from content");
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.areSame(i, Y.Widget.getByNode(innerContent), "Couldn't find inner widget from content");
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.areSame(o, Y.Widget.getByNode(o.get("contentBox")), "Couldn't find outer widget from outer contentBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame(o, Y.Widget.getByNode(o.get("boundingBox")), "Couldn't find outer widget from outer boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame(i, Y.Widget.getByNode(i.get("contentBox")), "Couldn't find inner widget from inner contentBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame(i, Y.Widget.getByNode(i.get("boundingBox")), "Couldn't find inner widget from inner boundingBox");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.ObjectAssert.ownsNoKeys(w.get("strings"), "No strings should be available by default");
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.areEqual("one", w.get("strings").stringOne);
c75976d12071ddd21443266260066ba036671682pawelw Y.Assert.areEqual("two", w.get("strings").stringTwo);
c75976d12071ddd21443266260066ba036671682pawelw Y.Assert.areEqual("three", w.get("strings").stringThree);
c75976d12071ddd21443266260066ba036671682pawelw Y.Assert.areEqual("four", w.get("strings").stringFour);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var n = Y.Node.create('<div id="srcNode" class="yui3-widget-loading">Src Node Content</div>');
8aa6aadbbfba50077655c6a46a5e269c880e4ab4Xiao-Yu Zhang Y.Assert.isTrue(n.hasClass("yui3-widget-loading"), "yui3-widget-loading should not have been removed");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame(n, w.get("contentBox"), "srcNode not used as content box");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(n.hasClass("yui3-widget-loading"), "yui3-widget-loading should have removed");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("focused"), "Widget should not be focused here");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var n = w.get("contentBox").appendChild('<a href="#" id="clickme">Click Me</a>');
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("focused"), "Widget should be focused here");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf var n = Y.Node.create('<div id="srcNode" class="yui3-mywidget-loading">Src Node Content</div>');
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(n.hasClass("yui3-mywidget-loading"), "yui3-mywidget-loading should not have been removed");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areSame(n, w.get("contentBox"), "srcNode not used as content box");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(n.hasClass("yui3-mywidget-loading"), "yui3-mywidget-loading should have removed");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass("yui3-widget"), "bb missing generic yui3-widget marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(bb.hasClass("yui3-mywidget"), "bb missing yui3-mywidget marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(cb.hasClass("yui3-mywidget-content"), "cb missing yui3-mywidget-content marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(cb.hasClass("yui3-widget-content"), "cb shouldn't have yui3-widget-content marker");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("yui3-mywidget", w._cssPrefix, "Unexpected Prefix");
f76ee27a7c2e4dbe22aec6ce187c04e980f90349pawelw Y.Assert.areEqual("yui3-mywidget-foo-bar", w.getClassName("foo", "bar"));
f76ee27a7c2e4dbe22aec6ce187c04e980f90349pawelw var singleBoxCoreTests = Y.Object(extendedCoreTests);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Doesn't make sense to pass 2 boxes into a single box widget.
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("disabled", true);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("height", 100);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("width", 200);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("visible", false);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf w.set("tabIndex", 5);
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("span", w.get("boundingBox").get("tagName").toLowerCase());
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("span", w.get("contentBox").get("tagName").toLowerCase());
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("bb", w.get("boundingBox").get("id"));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Doesn't make sense to pass 2 boxes into a single box widget.
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Y.Assert.areEqual("cb", w.get("contentBox").get("id"));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("disabled"), "disabled should be true");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("focused"), "focused should be false"); // focused is READONLY
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("100", w.get("height"), "height should be 100px");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("200", w.get("width"), "width should be 200px");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("foobar", w.get("id"), "id should be foobar");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("visible"), "visible should be false");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual(5, w.get("tabIndex"), "tabIndex should be 5");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.areEqual("yui3-mysingleboxwidget", w._cssPrefix, "Unexpected Prefix");
2038334ab26baaa43c9083f35def041511c3cc1fUnknown Y.Assert.areEqual("yui3-mysingleboxwidget-foo-bar", w.getClassName("foo", "bar"));
2038334ab26baaa43c9083f35def041511c3cc1fUnknown var n = Y.Node.create('<div id="srcNode" class="yui3-mysingleboxwidget-loading">Src Node Content</div>');
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(n.hasClass("yui3-mysingleboxwidget-loading"), "yui3-mysingleboxwidget-loading should not have been removed");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // FIXME: Include after this is fixed: http://yuilibrary.com/projects/yui3/ticket/2530076, 2530311.
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf // Y.Assert.areSame(n, w.get("contentBox"), "srcNode not used as content box");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isFalse(w.get("boundingBox").hasClass("yui3-mysingleboxwidget-loading"), "yui3-mysingleboxwidget-loading should have removed");
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue( w.get("boundingBox").compareTo(w.get("contentBox")));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(w.get("boundingBox").compareTo(w.get("contentBox")));
66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24mlf Y.Assert.isTrue(Y.one("#singleBox").compareTo(w.get("contentBox")));
Y.Assert.isTrue(bb.hasClass("yui3-mysingleboxwidget-content"), "cb missing yui3-mysingleboxwidget-content marker");
Y.Assert.isFalse(bb.hasClass("yui3-widget-content"), "cb shouldn't have yui3-widget-content marker");
w.render();
Y.Assert.isTrue(bbFromDom.compareTo(Y.Node.one("body").get("firstChild")), "widget not inserted to body");
w.destroy();
Y.Assert.isTrue(bbFromDom.get("parentNode").compareTo(Y.Node.one("#widgetRenderContainer")), "widget not rendered to container passed to render()");
w.destroy();
Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "boundingBox moved from it's place in the DOM");
w.destroy();
Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "contentBox moved from it's place in the DOM");
w.destroy();
Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "boundingBox moved from it's place in the DOM");
w.destroy();
Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "contentBox moved from it's place in the DOM");
w.destroy();
Y.Assert.isTrue(w.get("srcNode").compareTo(sn), "srcNode should still be accessible from srcNode attribute");
Y.Assert.isTrue(w.get("boundingBox").get("parentNode").compareTo(container), "srcNode moved from it's place in the DOM");
suite.add(new Y.Test.Case(coreTests));
suite.add(new Y.Test.Case(extendedCoreTests));
suite.add(new Y.Test.Case(singleBoxCoreTests));
return (new Y.Widget(cfg));
var w = this.createWidget({
actual.push("onInit");
actual.push("afterInit");
w.on("render", function() {
actual.push("onRender");
w.after("render", function() {
actual.push("afterRender");
w.on("destroy", function() {
actual.push("onDestroy");
w.after("destroy", function() {
actual.push("afterDestroy");
w.render();
w.render();
w.destroy();
Y.ArrayAssert.itemsAreEqual(expected, actual, "Unexpected Lifecycle Events");
var w = this.createWidget();
w.render();
w.on("init", function() {
actual.push("onInit");
w.after("init", function() {
actual.push("afterInit");
w.on("render", function() {
actual.push("onRender");
w.after("render", function() {
actual.push("afterRender");
w.render();
w.destroy();
listeners.on[attrs[i] + "Change"] = onListener;
listeners.after[attrs[i] + "Change"] = afterListener;
var w = this.createWidget(listeners);
w.render();
w.set("visible", false);
w.set("disabled", true);
w.set("height", "100px");
w.set("width", "100px");
w.set("strings", {newStrings: "foo"});
w.set("tabIndex", 7);
w.focus();
w.destroy();
Y.ArrayAssert.itemsAreEqual(expected, actual, "Unexpected attribute change events");
var w = this.createWidget(),
w.on("contentUpdate", function() {
actual.push("onContentUpdate");
w.after("contentUpdate", function() {
actual.push("afterContentUpdate");
w.fire("contentUpdate");
Y.ArrayAssert.itemsAreEqual(expected, actual, "Unexpected content update events");
w.destroy();
var extendedEventTests = Y.Object(coreEventTests);
Y.mix(extendedEventTests, {
this.__test.push("preconstructor");
MyLifecycleWidget.superclass.constructor.apply(this, arguments);
this.__test.push("postconstructor");
this.__test.push("renderUI");
this.__test.push("bindUI");
this.__test.push("syncUI");
this.__test.push("initializer");
var attr = this.get("lazyAttr");
this.__test.push("destructor");
this.__test.push("lazySetter");
this.__test.push("nonLazySetter");
MyLifecycleWidget.NAME = "myLifecycleWidget";
this.__test.push("onInit");
this.__test.push("onDestroy");
this.__test.push("onRender");
this.__test.push("afterInit");
this.__test.push("afterDestroy");
this.__test.push("afterRender");
w.destroy();
Y.ArrayAssert.itemsAreEqual(expected, w.__test, "Unexpected phase order");
this.__test.push("onInit");
this.__test.push("onDestroy");
this.__test.push("onRender");
this.__test.push("afterInit");
this.__test.push("afterDestroy");
this.__test.push("afterRender");
w.render();
w.render(); // Only once
w.destroy();
Y.ArrayAssert.itemsAreEqual(expected, w.__test, "Unexpected phase order");
MyCustomWidget.superclass.constructor.apply(this, arguments);
// FIXME: Ideally we should be able to do a this.get("titleNode") here. However,
var labelHolder = srcNode.one("> h1");
return labelHolder.get("text");
MyCustomWidget.NAME = "myCustomWidget";
w.render();
var bbFromDom = Y.Node.one("#customWidget");
Y.Assert.isTrue(bbFromDom.get("parentNode").compareTo(Y.Node.one("#customWidgetRenderContainer")), "Custom widget not rendered to container passed to render()");
Y.Assert.isTrue(bbFromDom.get("firstChild").compareTo(w.get("contentBox")), "contentBox not first child of boundingBox");
w.destroy();
var bbFromDom = Y.Node.one("#customWidget");
Y.Assert.isTrue(bbFromDom.get("parentNode").compareTo(Y.Node.one("#customWidgetRenderContainer")), "Custom widget not rendered to container passed to render()");
Y.Assert.isTrue(bbFromDom.get("firstChild").compareTo(w.get("contentBox")), "contentBox not first child of boundingBox");
w.destroy();
var bb = w.get("boundingBox");
w.destroy();
var bb = w.get("contentBox");
w.destroy();
w.render();
var bb = w.get("boundingBox");
Y.Assert.isTrue(bb.hasClass("yui3-mycustomwidget-hidden"), "custom bb should have a hidden marker class");
Y.Assert.areEqual("hidden", bb.getStyle("visibility"), "custom widget should not be visibility:hidden");
w.destroy();
w.render();
var actual = w.get("strings");
Y.ObjectAssert.areEqual(expected, actual, "Unexpected strings");
Y.ObjectAssert.areEqual(actual, expected, "Unexpected strings");
w.destroy();
w.destroy();
var markup = Y.Node.create('<div id="customWidgetContent"><h1>My Label</h1><ul><li>Item1</li><li>Item2</li></ul></div>');
Y.Node.one("body").append(markup);
Y.Assert.areEqual("h1", w.get("titleNode").get("tagName").toLowerCase(), "titleNode not picked up from markup");
Y.Assert.areSame("li", w.get("listNodes").item(0).get("tagName").toLowerCase(), "listNode 0 not picked up from markup");
Y.Assert.areSame("li", w.get("listNodes").item(1).get("tagName").toLowerCase(), "listNode 1 not picked up from markup");
Y.Assert.areSame("Item1", w.get("listNodes").item(0).get("text"), "listNode 0 not picked up from markup");
Y.Assert.areSame("Item2", w.get("listNodes").item(1).get("text"), "listNode 1 not picked up from markup");
w.destroy();
var w = new Y.Widget();
cb = bb.one( 'div' ),
w = new Y.Widget( {
var w = new Y.Widget().render(),
body = Y.one( 'body' );
body.removeClass( "yui3-skin-sam" );
body.addClass( "yui3-skin-sam" );
var w = new Y.Widget().render( '#testbed' ),
body = Y.one( 'body' );
body.addClass( "yui3-skin-sam" );
var w = new Y.Widget({id:"foo"}).render();
w.destroy();
var w = new Y.Widget({id:"foo"}).render();
w.get("contentBox").appendChild(nref);
w.destroy(true);
var w = new Y.Widget();
w.destroy();
w.render();
w.destroy();
w.render();
w.get("contentBox").appendChild(nref);
w.destroy(true);
w = new Y.Widget();
cb = w.get("contentBox");
w.on("click", h);
w.render();
cb.one(".et").simulate("click");
Y.ArrayAssert.itemsAreEqual(expectedEvents, actualEvents);
w.destroy();
w = new Y.Widget();
cb = w.get("contentBox");
w.on({
w.on("widget:mouseup", h);
w.on("foo|widget:mouseup", h);
w.on("mouseup", h);
w.after("widget:mouseup", h);
w.after("foo|widget:mouseup", h);
w.after("mouseup", h);
w.after({
w.render();
cb.one(".et").simulate("mousedown");
cb.one(".et").simulate("mouseup");
cb.one(".et").simulate("click");
Y.ArrayAssert.itemsAreEqual(expectedEvents, actualEvents);
w.destroy();
var outer = new Y.Widget();
var inner = new Y.Widget();
var ocb = outer.get('contentBox');
var icb = inner.get('contentBox');
outer.render();
inner.render(ocb);
ocb.one(".oet").simulate("click");
ocb.one(".iet").simulate("click");
Y.ArrayAssert.itemsAreEqual(expectedEvents, actualEvents);
w1 = new Y.Widget({render:true});
w1.on('click', function (e) {
actualEvents.push("clickOuter");
w2 = new Y1.Widget({render:".w2-container"});
w2.on('click', function (e) {
actualEvents.push("clickInner");
Y.Node.one(".miouter").simulate("click"); // only outer, once.
Y.Node.one(".miinner").simulate("click"); // inner, bubbled to outer (once each, without JS errors)
Y.ArrayAssert.itemsAreEqual(expectedEvents, actualEvents);
w1.destroy();
w2.destroy();
var a = new Y.Widget();
var b = new Y.Widget();
var c = new Y.Widget();
var a1 = Y.clone(a);
var a2 = Y.clone(a1);
var a3 = Y.clone(a2);
var b1 = Y.clone(b);
var b2 = Y.clone(b1);
var b3 = Y.clone(b2);
var c1 = Y.clone(c);
var c2 = Y.clone(c1);
var c3 = Y.clone(c2);
var a = new Y.Widget();
var b = new Y.Widget();
var c = new Y.Widget();
var o1 = Y.clone(o);
var o2 = Y.clone(o1);
var o3 = Y.clone(o2);
var a = new Y.Base();
var b = new Y.Base();
var c = new Y.Base();
var a1 = Y.clone(a);
var a2 = Y.clone(a1);
var a3 = Y.clone(a2);
var b1 = Y.clone(b);
var b2 = Y.clone(b1);
var b3 = Y.clone(b2);
var c1 = Y.clone(c);
var c2 = Y.clone(c1);
var c3 = Y.clone(c2);
var a = new Y.Base();
var b = new Y.Base();
var c = new Y.Base();
var o1 = Y.clone(o);
var o2 = Y.clone(o1);
var o3 = Y.clone(o2);
Y.Test.Runner.setName("Widget Tests");
Y.Test.Runner.add(suite);
Y.Test.Runner.once("begin", function() {
Y.one("#automationmsg").removeClass("msg-hidden");
Y.Test.Runner.once("complete", function() {
Y.one("#automationmsg").addClass("msg-hidden");
var console, runButton = Y.one("#btnRun");
runButton.set("value", "Run Tests");
runButton.set("disabled", false).on("click", function() {
console = new Y.Console({