| 1 |
<!DOCTYPE HTML> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> |
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" /> |
| 6 |
<meta name="apple-mobile-web-app-capable" content="yes" /> |
| 7 |
<title>IconContainer and IconItem Tests</title> |
| 8 |
<script type="text/javascript" src="../../../deviceTheme.js"></script> |
| 9 |
<script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script> |
| 10 |
<script language="JavaScript" type="text/javascript"> |
| 11 |
require([ |
| 12 |
"dojo/ready", |
| 13 |
"dijit/registry", |
| 14 |
"doh/runner", |
| 15 |
"dojox/mobile/IconContainer", |
| 16 |
"dojox/mobile/IconItem", |
| 17 |
"dojox/mobile", |
| 18 |
"dojox/mobile/compat", |
| 19 |
"dojox/mobile/parser" |
| 20 |
], function(ready, registry, runner, IconContainer, IconItem){ |
| 21 |
ready(function(){ |
| 22 |
runner.register("dojox.mobile.test.doh.IconContainerTests2", [ |
| 23 |
{ |
| 24 |
name: "test1", |
| 25 |
timeout: 3000, |
| 26 |
runTest: function(){ |
| 27 |
// Test case for #16868 |
| 28 |
var editableIconContainer = registry.byId("editableIconContainer1"); |
| 29 |
var item = registry.byId("item1"); |
| 30 |
try{ |
| 31 |
editableIconContainer.deleteItem(item); |
| 32 |
}catch(err){ |
| 33 |
runner.assertTrue(false, "deleteItem throws error! (#16868)"); |
| 34 |
} |
| 35 |
} |
| 36 |
}, |
| 37 |
{ |
| 38 |
name: "test2", |
| 39 |
timeout: 3000, |
| 40 |
runTest: function(){ |
| 41 |
// Test case for #15064 |
| 42 |
var editableIconContainer = registry.byId("editableIconContainer2"); |
| 43 |
var d = new runner.Deferred(); |
| 44 |
var errorCounter = 0; |
| 45 |
var errorMsg; |
| 46 |
// Before the fix of #15064, there used to be an error thrown when destroying |
| 47 |
// right after startEdit(). To test it, we cannot use a simple try-catch, because |
| 48 |
// this is about an error thrown by the setTimeout function which used to be set |
| 49 |
// by startEdit() in an editable IconContainer. Hence: |
| 50 |
window.onerror = function(msg, url, lineNumber){ |
| 51 |
errorCounter++; |
| 52 |
errorMsg = "After destroy: " + msg + "\nURL: " + url + |
| 53 |
"\nLine number: " + lineNumber; |
| 54 |
console.log(errorMsg); |
| 55 |
}; |
| 56 |
editableIconContainer.startEdit(); |
| 57 |
editableIconContainer.destroyRecursive(false/*preserveDom*/); |
| 58 |
// Check that no error has been thrown |
| 59 |
setTimeout(d.getTestCallback(function(){ |
| 60 |
runner.assertEqual(0, errorCounter, errorMsg); |
| 61 |
}), 2000); // smaller than the total timeout of the test case |
| 62 |
|
| 63 |
return d; |
| 64 |
} |
| 65 |
}, |
| 66 |
{ |
| 67 |
name: "test3", |
| 68 |
timeout: 3000, |
| 69 |
runTest: function(){ |
| 70 |
// Test case for #15064 |
| 71 |
var editableIconContainer = registry.byId("editableIconContainer3"); |
| 72 |
var item = registry.byId("item3"); |
| 73 |
var d = new runner.Deferred(); |
| 74 |
var errorCounter = 0; |
| 75 |
var errorMsg; |
| 76 |
// Before the fix of #15064, there used to be an error thrown when destroying |
| 77 |
// right after deleteItem(). To test it, we cannot use a simple try-catch, because |
| 78 |
// this is about an error thrown by the setTimeout function which used to be set |
| 79 |
// (indirectly) by deleteItem() in an editable IconContainer. Hence: |
| 80 |
window.onerror = function(msg, url, lineNumber){ |
| 81 |
errorCounter++; |
| 82 |
errorMsg = "After destroy: " + msg + "\nURL: " + url + |
| 83 |
"\nLine number: " + lineNumber; |
| 84 |
console.log(errorMsg); |
| 85 |
}; |
| 86 |
editableIconContainer.deleteItem(item); |
| 87 |
editableIconContainer.destroyRecursive(false/*preserveDom*/); |
| 88 |
// Check that no error has been thrown |
| 89 |
setTimeout(d.getTestCallback(function(){ |
| 90 |
runner.assertEqual(0, errorCounter, errorMsg); |
| 91 |
}), 2000); // smaller than the total timeout of the test case |
| 92 |
|
| 93 |
return d; |
| 94 |
} |
| 95 |
}, |
| 96 |
{ |
| 97 |
name: "test4", |
| 98 |
timeout: 3000, |
| 99 |
runTest: function(){ |
| 100 |
// Test case for #15064 |
| 101 |
var editableIconContainer = registry.byId("editableIconContainer4"); |
| 102 |
var item = registry.byId("item4"); |
| 103 |
var d = new runner.Deferred(); |
| 104 |
var errorCounter = 0; |
| 105 |
var errorMsg; |
| 106 |
// Before the fix of #15064, there used to be an error thrown when destroying |
| 107 |
// right after IconItem.highlight(). To test it, we cannot use a simple try-catch, because |
| 108 |
// this is about an error thrown by the setTimeout function which used to be set |
| 109 |
// by IconItem.highlight(). Hence: |
| 110 |
window.onerror = function(msg, url, lineNumber){ |
| 111 |
errorCounter++; |
| 112 |
errorMsg = "After destroy: " + msg + "\nURL: " + url + |
| 113 |
"\nLine number: " + lineNumber; |
| 114 |
console.log(errorMsg); |
| 115 |
}; |
| 116 |
item.highlight(); |
| 117 |
editableIconContainer.destroyRecursive(false/*preserveDom*/); |
| 118 |
// Check that no error has been thrown |
| 119 |
setTimeout(d.getTestCallback(function(){ |
| 120 |
runner.assertEqual(0, errorCounter, errorMsg); |
| 121 |
}), 2000); // smaller than the total timeout of the test case |
| 122 |
|
| 123 |
return d; |
| 124 |
} |
| 125 |
} |
| 126 |
]); |
| 127 |
runner.run(); |
| 128 |
}); |
| 129 |
}) |
| 130 |
</script> |
| 131 |
</head> |
| 132 |
<body> |
| 133 |
|
| 134 |
<div data-dojo-type="dojox/mobile/View"> |
| 135 |
<h1>View 1</h1> |
| 136 |
<ul id="editableIconContainer1" data-dojo-type="dojox/mobile/IconContainer" |
| 137 |
data-dojo-props="editable: true"> |
| 138 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app1", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 139 |
<li id="item1" data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app2", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 140 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app3", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 141 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"moveTo", icon:"../../images/icon-1.png", moveTo:"about", transition:"slide"'></li> |
| 142 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"href", icon:"../../images/icon-1.png", href:"../../test_iPhone-RoundRectList.html", transition:"slide"'></li> |
| 143 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"url" , icon:"../../images/icon-1.png", url:"../../view-sample.html", transition:"slide"'></li> |
| 144 |
</ul> |
| 145 |
</div> |
| 146 |
|
| 147 |
|
| 148 |
<div id="view2" data-dojo-type="dojox/mobile/View"> |
| 149 |
<h1>View 2</h1> |
| 150 |
<ul id="editableIconContainer2" data-dojo-type="dojox/mobile/IconContainer" |
| 151 |
data-dojo-props="editable: true"> |
| 152 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app1", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 153 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app2", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 154 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app3", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 155 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"moveTo", icon:"../../images/icon-1.png", moveTo:"about", transition:"slide"'></li> |
| 156 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"href", icon:"../../images/icon-1.png", href:"../../test_iPhone-RoundRectList.html", transition:"slide"'></li> |
| 157 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"url" , icon:"../../images/icon-1.png", url:"../../view-sample.html", transition:"slide"'></li> |
| 158 |
</ul> |
| 159 |
<ul id="editableIconContainer3" data-dojo-type="dojox/mobile/IconContainer" |
| 160 |
data-dojo-props="editable: true"> |
| 161 |
<li id="item3" data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app1", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 162 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app2", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 163 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app3", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 164 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"moveTo", icon:"../../images/icon-1.png", moveTo:"about", transition:"slide"'></li> |
| 165 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"href", icon:"../../images/icon-1.png", href:"../../test_iPhone-RoundRectList.html", transition:"slide"'></li> |
| 166 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"url" , icon:"../../images/icon-1.png", url:"../../view-sample.html", transition:"slide"'></li> |
| 167 |
</ul> |
| 168 |
<ul id="editableIconContainer4" data-dojo-type="dojox/mobile/IconContainer" |
| 169 |
data-dojo-props="editable: true"> |
| 170 |
<li id="item4" data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app1", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 171 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app2", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 172 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"app3", icon:"../../images/icon-1.png", lazy:"true"'><div class="box"></div></li> |
| 173 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"moveTo", icon:"../../images/icon-1.png", moveTo:"about", transition:"slide"'></li> |
| 174 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"href", icon:"../../images/icon-1.png", href:"../../test_iPhone-RoundRectList.html", transition:"slide"'></li> |
| 175 |
<li data-dojo-type="dojox/mobile/IconItem" data-dojo-props='label:"url" , icon:"../../images/icon-1.png", url:"../../view-sample.html", transition:"slide"'></li> |
| 176 |
</ul> |
| 177 |
</div> |
| 178 |
|
| 179 |
</body> |
| 180 |
</html> |