browser/devtools/tilt/test/browser_tilt_utils06.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3 "use strict";
michael@0 4
michael@0 5 let someObject = {
michael@0 6 a: 1,
michael@0 7 func: function()
michael@0 8 {
michael@0 9 this.b = 2;
michael@0 10 }
michael@0 11 };
michael@0 12
michael@0 13 let anotherObject = {
michael@0 14 _finalize: function()
michael@0 15 {
michael@0 16 someObject.c = 3;
michael@0 17 }
michael@0 18 };
michael@0 19
michael@0 20 function test() {
michael@0 21 ok(TiltUtils, "The TiltUtils object doesn't exist.");
michael@0 22
michael@0 23 TiltUtils.bindObjectFunc(someObject, "", anotherObject);
michael@0 24 someObject.func();
michael@0 25
michael@0 26 is(someObject.a, 1,
michael@0 27 "The bindObjectFunc() messed the non-function members of the object.");
michael@0 28 isnot(someObject.b, 2,
michael@0 29 "The bindObjectFunc() didn't ignore the old scope correctly.");
michael@0 30 is(anotherObject.b, 2,
michael@0 31 "The bindObjectFunc() didn't set the new scope correctly.");
michael@0 32
michael@0 33
michael@0 34 TiltUtils.destroyObject(anotherObject);
michael@0 35 is(someObject.c, 3,
michael@0 36 "The finalize function wasn't called when an object was destroyed.");
michael@0 37
michael@0 38
michael@0 39 TiltUtils.destroyObject(someObject);
michael@0 40 is(typeof someObject.a, "undefined",
michael@0 41 "Not all members of the destroyed object were deleted.");
michael@0 42 is(typeof someObject.func, "undefined",
michael@0 43 "Not all function members of the destroyed object were deleted.");
michael@0 44 }

mercurial