1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_utils06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 +"use strict"; 1.7 + 1.8 +let someObject = { 1.9 + a: 1, 1.10 + func: function() 1.11 + { 1.12 + this.b = 2; 1.13 + } 1.14 +}; 1.15 + 1.16 +let anotherObject = { 1.17 + _finalize: function() 1.18 + { 1.19 + someObject.c = 3; 1.20 + } 1.21 +}; 1.22 + 1.23 +function test() { 1.24 + ok(TiltUtils, "The TiltUtils object doesn't exist."); 1.25 + 1.26 + TiltUtils.bindObjectFunc(someObject, "", anotherObject); 1.27 + someObject.func(); 1.28 + 1.29 + is(someObject.a, 1, 1.30 + "The bindObjectFunc() messed the non-function members of the object."); 1.31 + isnot(someObject.b, 2, 1.32 + "The bindObjectFunc() didn't ignore the old scope correctly."); 1.33 + is(anotherObject.b, 2, 1.34 + "The bindObjectFunc() didn't set the new scope correctly."); 1.35 + 1.36 + 1.37 + TiltUtils.destroyObject(anotherObject); 1.38 + is(someObject.c, 3, 1.39 + "The finalize function wasn't called when an object was destroyed."); 1.40 + 1.41 + 1.42 + TiltUtils.destroyObject(someObject); 1.43 + is(typeof someObject.a, "undefined", 1.44 + "Not all members of the destroyed object were deleted."); 1.45 + is(typeof someObject.func, "undefined", 1.46 + "Not all function members of the destroyed object were deleted."); 1.47 +}