inheritance.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Virtual World Framework</title>
  5. <script type="text/javascript" src="qunit.js"></script>
  6. <script type="text/javascript" src="../lib/async.js"></script>
  7. <script type="text/javascript" src="../lib/crypto.js"></script>
  8. <script type="text/javascript" src="../lib/md5.js"></script>
  9. <script type="text/javascript" src="../lib/alea.js"></script>
  10. <script type="text/javascript" src="../lib/mash.js"></script>
  11. <script type="text/javascript" src="../lib/vwf.js"></script>
  12. <script type="text/javascript" src="../lib/require.js"></script>
  13. <script type="text/javascript">
  14. require( {
  15. baseUrl: "../lib",
  16. paths: {
  17. jquery: "jquery-1.10.2.min",
  18. },
  19. }, [
  20. "domReady",
  21. "utility.js",
  22. // This is the common model implementation and an example model that connects the
  23. // simulation to a WebGL scene manager.
  24. "jquery",
  25. "vwf/configuration",
  26. "vwf/kernel/model",
  27. "vwf/model/javascript",
  28. "vwf/model/object",
  29. "vwf/model/stage/log",
  30. "vwf/kernel/view",
  31. "vwf/kernel/utility",
  32. "vwf/utility",
  33. "logger",
  34. ], function( ready, testUtility ) {
  35. // Verify that prototype-based inheritance in VWF works the same way as in JavaScript.
  36. ready( function() {
  37. vwf.initialize(
  38. /* models */ [ "vwf/model/javascript", "vwf/model/object" ],
  39. /* views */ [ ]
  40. );
  41. test( "Models", function() {
  42. equal( vwf.models.actual[0].module.id, "vwf/model/javascript", "JavaScript Model" );
  43. equal( vwf.models.actual[1].module.id, "vwf/model/object", "Object Model" );
  44. } );
  45. test( "Views", function() {
  46. expect(0);
  47. } );
  48. // Validate the fixture.
  49. test( "Property Inheritance fixture JS", function() {
  50. var fixture = createFixtureJS( "empty", "value", "accessor" );
  51. equal( fixture.top.tag, "top", "top tag" );
  52. ok( ! fixture.top.hasOwnProperty( "property" ) ); // "empty" type
  53. ok( ! fixture.top.hasOwnProperty( "property_" ) ); // "empty" type
  54. equal( fixture.middle.tag, "middle", "middle tag" );
  55. ok( fixture.middle.hasOwnProperty( "property" ) ); // "value" type
  56. ok( ! fixture.middle.hasOwnProperty( "property_" ) ); // "value" type
  57. equal( fixture.bottom.tag, "bottom", "bottom tag" );
  58. ok( fixture.bottom.hasOwnProperty( "property" ) ); // "accessor" type
  59. ok( fixture.bottom.hasOwnProperty( "property_" ) ); // "accessor" type
  60. } );
  61. // Validate the fixture.
  62. asyncTest( "Property Inheritance fixture VWF", function() {
  63. createFixtureVWF( "empty", "value", "accessor", function( fixture, cleanup ) {
  64. equal( vwf.execute( fixture.top, "this.tag" ), "top", "top tag" );
  65. ok( ! vwf.execute( fixture.top, "this.hasOwnProperty( 'property' )" ) ); // "empty" type
  66. // ok( ! fixture.top.hasOwnProperty( "property_" ) ); // "empty" type // TODO: vwf/model/javascript internals
  67. equal( vwf.execute( fixture.middle, "this.tag" ), "middle", "middle tag" );
  68. ok( vwf.execute( fixture.middle, "this.hasOwnProperty( 'property' )" ) ); // "value" type
  69. // ok( ! fixture.middle.hasOwnProperty( "property_" ) ); // "value" type // TODO: vwf/model/javascript internals
  70. equal( vwf.execute( fixture.bottom, "this.tag" ), "bottom", "bottom tag" );
  71. ok( vwf.execute( fixture.bottom, "this.hasOwnProperty( 'property' )" ) ); // "accessor" type
  72. // ok( fixture.bottom.hasOwnProperty( "property_" ) ); // "accessor" type // TODO: vwf/model/javascript internals
  73. cleanup();
  74. start();
  75. } );
  76. } );
  77. // With no prior values, gets return undefined, and sets apply directly to the top.
  78. test( "Property Inheritance JS: empty, empty, empty", function() {
  79. var fixture = createFixtureJS( "empty", "empty", "empty" );
  80. equal( fixture.top.property, undefined, "top before" );
  81. equal( fixture.middle.property, undefined, "middle before" );
  82. equal( fixture.bottom.property, undefined, "bottom before" );
  83. fixture.top.property = "UpDaTeD";
  84. equal( fixture.top.property, "UpDaTeD", "top after" );
  85. equal( fixture.middle.property, undefined, "middle after" );
  86. equal( fixture.bottom.property, undefined, "bottom after" );
  87. } );
  88. // With no prior values, gets return undefined, and sets apply directly to the top.
  89. asyncTest( "Property Inheritance VWF: empty, empty, empty", function() {
  90. createFixtureVWF( "empty", "empty", "empty", function( fixture, cleanup ) {
  91. equal( vwf.getProperty( fixture.top, "property" ), undefined, "top before" );
  92. equal( vwf.getProperty( fixture.middle, "property" ), undefined, "middle before" );
  93. equal( vwf.getProperty( fixture.bottom, "property" ), undefined, "bottom before" );
  94. vwf.setProperty( fixture.top, "property", "UpDaTeD" );
  95. equal( vwf.getProperty( fixture.top, "property" ), "UpDaTeD", "top after" );
  96. equal( vwf.getProperty( fixture.middle, "property" ), undefined, "middle after" );
  97. equal( vwf.getProperty( fixture.bottom, "property" ), undefined, "bottom after" );
  98. cleanup();
  99. start();
  100. } );
  101. } );
  102. test( "Property Inheritance JS: empty, empty, value", function() {
  103. var fixture = createFixtureJS( "empty", "empty", "value" );
  104. equal( fixture.top.property, "bottom", "top before" );
  105. equal( fixture.middle.property, "bottom", "middle before" );
  106. equal( fixture.bottom.property, "bottom", "bottom before" );
  107. fixture.top.property = "UpDaTeD";
  108. equal( fixture.top.property, "UpDaTeD", "top after" );
  109. equal( fixture.middle.property, "bottom", "middle after" );
  110. equal( fixture.bottom.property, "bottom", "bottom after" );
  111. } );
  112. asyncTest( "Property Inheritance VWF: empty, empty, value", function() {
  113. createFixtureVWF( "empty", "empty", "value", function( fixture, cleanup ) {
  114. equal( vwf.getProperty( fixture.top, "property" ), "bottom", "top before" );
  115. equal( vwf.getProperty( fixture.middle, "property" ), "bottom", "middle before" );
  116. equal( vwf.getProperty( fixture.bottom, "property" ), "bottom", "bottom before" );
  117. vwf.setProperty( fixture.top, "property", "UpDaTeD" );
  118. equal( vwf.getProperty( fixture.top, "property" ), "UpDaTeD", "top after" );
  119. equal( vwf.getProperty( fixture.middle, "property" ), "bottom", "middle after" );
  120. equal( vwf.getProperty( fixture.bottom, "property" ), "bottom", "bottom after" );
  121. cleanup();
  122. start();
  123. } );
  124. } );
  125. test( "Property Inheritance JS: empty, empty, accessor", function() {
  126. var fixture = createFixtureJS( "empty", "empty", "accessor" );
  127. equal( fixture.top.property, "BOTTOM", "top before" ); // via accessor on bottom
  128. ok( ! fixture.top.hasOwnProperty( "property_" ) );
  129. equal( fixture.middle.property, "BOTTOM", "middle before" );
  130. equal( fixture.bottom.property, "BOTTOM", "bottom before" );
  131. fixture.top.property = "UpDaTeD"; // through accessor on bottom
  132. equal( fixture.top.property, "UPDATED", "top after" ); // via accessor on bottom using value on top
  133. ok( fixture.top.hasOwnProperty( "property_" ) );
  134. equal( fixture.top.property_, "updated" );
  135. equal( fixture.middle.property, "BOTTOM", "middle after" );
  136. equal( fixture.bottom.property, "BOTTOM", "bottom after" );
  137. } );
  138. asyncTest( "Property Inheritance VWF: empty, empty, accessor", function() {
  139. createFixtureVWF( "empty", "empty", "accessor", function( fixture, cleanup ) {
  140. equal( vwf.getProperty( fixture.top, "property" ), "BOTTOM", "top before" ); // via accessor on bottom
  141. // ok( ! fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  142. equal( vwf.getProperty( fixture.middle, "property" ), "BOTTOM", "middle before" );
  143. equal( vwf.getProperty( fixture.bottom, "property" ), "BOTTOM", "bottom before" );
  144. vwf.setProperty( fixture.top, "property", "UpDaTeD" ); // through accessor on bottom
  145. equal( vwf.getProperty( fixture.top, "property" ), "UPDATED", "top after" );
  146. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  147. // equal( fixture.top.property_, "updated" ); // TODO: vwf/model/object internals
  148. equal( vwf.getProperty( fixture.middle, "property" ), "BOTTOM", "middle after" );
  149. equal( vwf.getProperty( fixture.bottom, "property" ), "BOTTOM", "bottom after" );
  150. cleanup();
  151. start();
  152. } );
  153. } );
  154. test( "Property Inheritance JS: value, empty, empty", function() {
  155. var fixture = createFixtureJS( "value", "empty", "empty" );
  156. equal( fixture.top.property, "top", "top before" );
  157. equal( fixture.middle.property, undefined, "middle before" );
  158. equal( fixture.bottom.property, undefined, "bottom before" );
  159. fixture.top.property = "UpDaTeD";
  160. equal( fixture.top.property, "UpDaTeD", "top after" );
  161. equal( fixture.middle.property, undefined, "middle after" );
  162. equal( fixture.bottom.property, undefined, "bottom after" );
  163. } );
  164. asyncTest( "Property Inheritance VWF: value, empty, empty", function() {
  165. createFixtureVWF( "value", "empty", "empty", function( fixture, cleanup ) {
  166. equal( vwf.getProperty( fixture.top, "property" ), "top", "top before" );
  167. equal( vwf.getProperty( fixture.middle, "property" ), undefined, "middle before" );
  168. equal( vwf.getProperty( fixture.bottom, "property" ), undefined, "bottom before" );
  169. vwf.setProperty( fixture.top, "property", "UpDaTeD" );
  170. equal( vwf.getProperty( fixture.top, "property" ), "UpDaTeD", "top after" );
  171. equal( vwf.getProperty( fixture.middle, "property" ), undefined, "middle after" );
  172. equal( vwf.getProperty( fixture.bottom, "property" ), undefined, "bottom after" );
  173. cleanup();
  174. start();
  175. } );
  176. } );
  177. test( "Property Inheritance JS: value, empty, value", function() {
  178. var fixture = createFixtureJS( "value", "empty", "value" );
  179. equal( fixture.top.property, "top", "top before" );
  180. equal( fixture.middle.property, "bottom", "middle before" );
  181. equal( fixture.bottom.property, "bottom", "bottom before" );
  182. fixture.top.property = "UpDaTeD";
  183. equal( fixture.top.property, "UpDaTeD", "top after" );
  184. equal( fixture.middle.property, "bottom", "middle after" );
  185. equal( fixture.bottom.property, "bottom", "bottom after" );
  186. } );
  187. asyncTest( "Property Inheritance VWF: value, empty, value", function() {
  188. createFixtureVWF( "value", "empty", "value", function( fixture, cleanup ) {
  189. equal( vwf.getProperty( fixture.top, "property" ), "top", "top before" );
  190. equal( vwf.getProperty( fixture.middle, "property" ), "bottom", "middle before" );
  191. equal( vwf.getProperty( fixture.bottom, "property" ), "bottom", "bottom before" );
  192. vwf.setProperty( fixture.top, "property", "UpDaTeD" );
  193. equal( vwf.getProperty( fixture.top, "property" ), "UpDaTeD", "top after" );
  194. equal( vwf.getProperty( fixture.middle, "property" ), "bottom", "middle after" );
  195. equal( vwf.getProperty( fixture.bottom, "property" ), "bottom", "bottom after" );
  196. cleanup();
  197. start();
  198. } );
  199. } );
  200. test( "Property Inheritance JS: value, empty, accessor", function() {
  201. var fixture = createFixtureJS( "value", "empty", "accessor" );
  202. equal( fixture.top.property, "top", "top before" );
  203. ok( ! fixture.top.hasOwnProperty( "property_" ) );
  204. equal( fixture.middle.property, "BOTTOM", "middle before" );
  205. equal( fixture.bottom.property, "BOTTOM", "bottom before" );
  206. fixture.top.property = "UpDaTeD"; // not using accessor on bottom
  207. equal( fixture.top.property, "UpDaTeD", "top after" );
  208. ok( ! fixture.top.hasOwnProperty( "property_" ) );
  209. equal( fixture.middle.property, "BOTTOM", "middle after" );
  210. equal( fixture.bottom.property, "BOTTOM", "bottom after" );
  211. } );
  212. asyncTest( "Property Inheritance VWF: value, empty, accessor", function() {
  213. createFixtureVWF( "value", "empty", "accessor", function( fixture, cleanup ) {
  214. equal( vwf.getProperty( fixture.top, "property" ), "top", "top before" );
  215. // ok( ! fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  216. equal( vwf.getProperty( fixture.middle, "property" ), "BOTTOM", "middle before" );
  217. equal( vwf.getProperty( fixture.bottom, "property" ), "BOTTOM", "bottom before" );
  218. vwf.setProperty( fixture.top, "property", "UpDaTeD" ); // not using accessor on bottom
  219. equal( vwf.getProperty( fixture.top, "property" ), "UpDaTeD", "top after" );
  220. // ok( ! fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  221. equal( vwf.getProperty( fixture.middle, "property" ), "BOTTOM", "middle after" );
  222. equal( vwf.getProperty( fixture.bottom, "property" ), "BOTTOM", "bottom after" );
  223. cleanup();
  224. start();
  225. } );
  226. } );
  227. test( "Property Inheritance JS: accessor, empty, empty", function() {
  228. var fixture = createFixtureJS( "accessor", "empty", "empty" );
  229. equal( fixture.top.property, "TOP", "top before" ); // via accessor on top
  230. ok( fixture.top.hasOwnProperty( "property_" ) );
  231. equal( fixture.top.property_, "top" );
  232. equal( fixture.middle.property, undefined, "middle before" );
  233. equal( fixture.bottom.property, undefined, "bottom before" );
  234. fixture.top.property = "UpDaTeD"; // through accessor on top
  235. equal( fixture.top.property, "UPDATED", "top after" ); // via accessor on top using value on top
  236. ok( fixture.top.hasOwnProperty( "property_" ) );
  237. equal( fixture.top.property_, "updated" );
  238. equal( fixture.middle.property, undefined, "middle after" );
  239. equal( fixture.bottom.property, undefined, "bottom after" );
  240. } );
  241. asyncTest( "Property Inheritance VWF: accessor, empty, empty", function() {
  242. createFixtureVWF( "accessor", "empty", "empty", function( fixture, cleanup ) {
  243. equal( vwf.getProperty( fixture.top, "property" ), "TOP", "top before" ); // via accessor on top
  244. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  245. // equal( fixture.top.property_, "top" ); // TODO: vwf/model/object internals
  246. equal( vwf.getProperty( fixture.middle, "property" ), undefined, "middle before" );
  247. equal( vwf.getProperty( fixture.bottom, "property" ), undefined, "bottom before" );
  248. vwf.setProperty( fixture.top, "property", "UpDaTeD" ); // through accessor on top
  249. equal( vwf.getProperty( fixture.top, "property" ), "UPDATED", "top after" ); // via accessor on top using value on top
  250. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  251. // equal( fixture.top.property_, "updated" ); // TODO: vwf/model/object internals
  252. equal( vwf.getProperty( fixture.middle, "property" ), undefined, "middle after" );
  253. equal( vwf.getProperty( fixture.bottom, "property" ), undefined, "bottom after" );
  254. cleanup();
  255. start();
  256. } );
  257. } );
  258. test( "Property Inheritance JS: accessor, empty, value", function() {
  259. var fixture = createFixtureJS( "accessor", "empty", "value" );
  260. equal( fixture.top.property, "TOP", "top before" ); // via accessor on top
  261. ok( fixture.top.hasOwnProperty( "property_" ) );
  262. equal( fixture.top.property_, "top" );
  263. equal( fixture.middle.property, "bottom", "middle before" );
  264. equal( fixture.bottom.property, "bottom", "bottom before" );
  265. fixture.top.property = "UpDaTeD"; // through accessor on top
  266. equal( fixture.top.property, "UPDATED", "top after" ); // via accessor on top using value on top
  267. ok( fixture.top.hasOwnProperty( "property_" ) );
  268. equal( fixture.top.property_, "updated" );
  269. equal( fixture.middle.property, "bottom", "middle after" );
  270. equal( fixture.bottom.property, "bottom", "bottom after" );
  271. } );
  272. asyncTest( "Property Inheritance VWF: accessor, empty, value", function() {
  273. createFixtureVWF( "accessor", "empty", "value", function( fixture, cleanup ) {
  274. equal( vwf.getProperty( fixture.top, "property" ), "TOP", "top before" ); // via accessor on top
  275. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  276. // equal( fixture.top.property_, "top" ); // TODO: vwf/model/object internals
  277. equal( vwf.getProperty( fixture.middle, "property" ), "bottom", "middle before" );
  278. equal( vwf.getProperty( fixture.bottom, "property" ), "bottom", "bottom before" );
  279. vwf.setProperty( fixture.top, "property", "UpDaTeD" ); // through accessor on top
  280. equal( vwf.getProperty( fixture.top, "property" ), "UPDATED", "top after" ); // via accessor on top using value on top
  281. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  282. // equal( fixture.top.property_, "updated" ); // TODO: vwf/model/object internals
  283. equal( vwf.getProperty( fixture.middle, "property" ), "bottom", "middle after" );
  284. equal( vwf.getProperty( fixture.bottom, "property" ), "bottom", "bottom after" );
  285. cleanup();
  286. start();
  287. } );
  288. } );
  289. test( "Property Inheritance JS: accessor, empty, accessor", function() {
  290. var fixture = createFixtureJS( "accessor", "empty", "accessor" );
  291. equal( fixture.top.property, "TOP", "top before" ); // via accessor on top
  292. ok( fixture.top.hasOwnProperty( "property_" ) );
  293. equal( fixture.top.property_, "top" );
  294. equal( fixture.middle.property, "BOTTOM", "middle before" );
  295. equal( fixture.bottom.property, "BOTTOM", "bottom before" );
  296. fixture.top.property = "UpDaTeD"; // through accessor on top
  297. equal( fixture.top.property, "UPDATED", "top after" ); // via accessor on top using value on top
  298. ok( fixture.top.hasOwnProperty( "property_" ) );
  299. equal( fixture.top.property_, "updated" );
  300. equal( fixture.middle.property, "BOTTOM", "middle after" );
  301. equal( fixture.bottom.property, "BOTTOM", "bottom after" );
  302. } );
  303. asyncTest( "Property Inheritance VWF: accessor, empty, accessor", function() {
  304. createFixtureVWF( "accessor", "empty", "accessor", function( fixture, cleanup ) {
  305. equal( vwf.getProperty( fixture.top, "property" ), "TOP", "top before" ); // via accessor on top
  306. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  307. // equal( fixture.top.property_, "top" ); // TODO: vwf/model/object internals
  308. equal( vwf.getProperty( fixture.middle, "property" ), "BOTTOM", "middle before" );
  309. equal( vwf.getProperty( fixture.bottom, "property" ), "BOTTOM", "bottom before" );
  310. vwf.setProperty( fixture.top, "property", "UpDaTeD" ); // through accessor on top
  311. equal( vwf.getProperty( fixture.top, "property" ), "UPDATED", "top after" ); // via accessor on top using value on top
  312. // ok( fixture.top.hasOwnProperty( "property_" ) ); // TODO: vwf/model/object internals
  313. // equal( fixture.top.property_, "updated" ); // TODO: vwf/model/object internals
  314. equal( vwf.getProperty( fixture.middle, "property" ), "BOTTOM", "middle after" );
  315. equal( vwf.getProperty( fixture.bottom, "property" ), "BOTTOM", "bottom after" );
  316. cleanup();
  317. start();
  318. } );
  319. } );
  320. // == Helper functions =====================================================================
  321. // Create a regular JavaScript object with three levels of inheritance using the given
  322. // constructors. Tag each level with a unique identifier.
  323. function createFixtureJS( top, middle, bottom ) {
  324. // Factories for constructor functions for the various cases.
  325. var factories = {
  326. // No "property" property.
  327. empty: function( tag ) {
  328. return function() {
  329. this.tag = tag;
  330. }
  331. },
  332. // "property" as a simple value type.
  333. value: function( tag ) {
  334. return function() {
  335. Object.defineProperty( this, "property", {
  336. value: tag,
  337. writable: true
  338. } );
  339. this.tag = tag;
  340. }
  341. },
  342. // "property" with getter and setter functions.
  343. accessor: function( tag ) {
  344. return function() {
  345. Object.defineProperty( this, "property", {
  346. get: function() { return this.property_.toUpperCase() },
  347. set: function( value ) { this.property_ = value.toLowerCase() }
  348. } );
  349. this.property_ = tag;
  350. this.tag = tag;
  351. }
  352. },
  353. };
  354. // Construct the three-level inheritance pattern: top : middle : bottom.
  355. var bc = factories[bottom]( "bottom" ); // constructor
  356. var bi = new bc(); // instance
  357. var mc = factories[middle]( "middle" ); mc.prototype = bi; // constructor
  358. var mi = new mc(); // instance
  359. var tc = factories[top]( "top" ); tc.prototype = mi; // constructor
  360. var ti = new tc(); // instance
  361. // Return the instances at all three levels.
  362. return { top: ti, middle: mi, bottom: bi };
  363. }
  364. // Create a VWF object with three levels of inheritance using the given configurations.
  365. function createFixtureVWF( top, middle, bottom, callback ) {
  366. // Factories for property initializers for the various cases.
  367. var factories = {
  368. // No "property" property.
  369. empty: function( tag ) {
  370. return undefined;
  371. },
  372. // "property" as a simple value type.
  373. value: function( tag ) {
  374. return {
  375. property: { value: tag, create: true }
  376. };
  377. },
  378. // "property" with getter and setter functions.
  379. accessor: function( tag ) {
  380. return {
  381. property: {
  382. get: "return this.property && this.property.toUpperCase()",
  383. set: "this.property = value.toLowerCase()",
  384. value: tag
  385. }
  386. };
  387. },
  388. };
  389. // Construct the three-level inheritance pattern: top : middle : bottom.
  390. var bottomProperties = factories[bottom]( "bottom" );
  391. var middleProperties = factories[middle]( "middle" );
  392. var topProperties = factories[top]( "top" );
  393. vwf.createNode( { extends: "http://vwf.example.com/node.vwf", properties: bottomProperties }, function( bottomID ) {
  394. vwf.execute( bottomID, "this.tag = 'bottom'" );
  395. vwf.createNode( { extends: bottomID, properties: middleProperties }, function( middleID ) {
  396. vwf.execute( middleID, "this.tag = 'middle'" );
  397. vwf.createNode( { extends: middleID, properties: topProperties }, function( topID ) {
  398. vwf.execute( topID, "this.tag = 'top'" );
  399. callback( { top: topID, middle: middleID, bottom: bottomID }, function() {
  400. vwf.deleteNode( topID );
  401. vwf.deleteNode( middleID );
  402. vwf.deleteNode( bottomID );
  403. } );
  404. } );
  405. } );
  406. } );
  407. }
  408. } );
  409. } );
  410. </script>
  411. <link rel="stylesheet" type="text/css" href="qunit.css" />
  412. </head>
  413. <body>
  414. <h1 id="qunit-header">Virtual World Framework</h1>
  415. <h2 id="qunit-banner"></h2>
  416. <div id="qunit-testrunner-toolbar"></div>
  417. <h2 id="qunit-userAgent"></h2>
  418. <ol id="qunit-tests"></ol>
  419. <div id="qunit-fixture">test markup, will be hidden</div>
  420. </body>
  421. </html>