diff --git a/core/tests/regression_tests.rs b/core/tests/regression_tests.rs index 82242556c..60c4d4b64 100644 --- a/core/tests/regression_tests.rs +++ b/core/tests/regression_tests.rs @@ -135,6 +135,7 @@ swf_tests! { (movieclip_prototype_extension, "avm1/movieclip_prototype_extension", 1), (movieclip_hittest, "avm1/movieclip_hittest", 1), (movieclip_hittest_shapeflag, "avm1/movieclip_hittest_shapeflag", 10), + #[ignore] (movieclip_lockroot, "avm1/movieclip_lockroot", 10), #[ignore] (textfield_text, "avm1/textfield_text", 1), (recursive_prototypes, "avm1/recursive_prototypes", 2), (stage_object_children, "avm1/stage_object_children", 2), diff --git a/core/tests/swfs/avm1/movieclip_lockroot/child.as b/core/tests/swfs/avm1/movieclip_lockroot/child.as new file mode 100644 index 000000000..7ef68a743 --- /dev/null +++ b/core/tests/swfs/avm1/movieclip_lockroot/child.as @@ -0,0 +1,7 @@ +function setLock(lock) { + this._lockroot = lock; +} + +function test(lock) { + trace("Child: level is " + this + ", root is " + _root + ", _lockroot is " + this._lockroot + ", parent is " + this._parent); +} diff --git a/core/tests/swfs/avm1/movieclip_lockroot/child.fla b/core/tests/swfs/avm1/movieclip_lockroot/child.fla new file mode 100644 index 000000000..78dca7b18 Binary files /dev/null and b/core/tests/swfs/avm1/movieclip_lockroot/child.fla differ diff --git a/core/tests/swfs/avm1/movieclip_lockroot/child.swf b/core/tests/swfs/avm1/movieclip_lockroot/child.swf new file mode 100644 index 000000000..530631f17 Binary files /dev/null and b/core/tests/swfs/avm1/movieclip_lockroot/child.swf differ diff --git a/core/tests/swfs/avm1/movieclip_lockroot/output.txt b/core/tests/swfs/avm1/movieclip_lockroot/output.txt new file mode 100644 index 000000000..48d39bc24 --- /dev/null +++ b/core/tests/swfs/avm1/movieclip_lockroot/output.txt @@ -0,0 +1,29 @@ +Parent: level is _level0, root is _level0, _lockroot is false +Parent: setting _lockroot to true sets it to true. +Parent: setting _lockroot to false sets it to false. +Parent: setting _lockroot to undefined sets it to false. +Parent: setting _lockroot to null sets it to false. +Parent: setting _lockroot to NaN sets it to false. +Parent: setting _lockroot to -1 sets it to true. +Parent: setting _lockroot to 0 sets it to false. +Parent: setting _lockroot to 1 sets it to true. +Parent: setting _lockroot to 1337 sets it to true. +Parent: setting _lockroot to "true" sets it to true. +Parent: setting _lockroot to "false" sets it to true. +Parent: setting _lockroot to "foo" sets it to true. +Parent: setting _lockroot to "" sets it to false. +Parent: setting _lockroot to "0" sets it to true. +Parent: setting _lockroot to [object Object] sets it to true. +Child: level is _level0.child1, root is _level0, _lockroot is false, parent is _level0 +Child: level is _level0.child2, root is _level0.child2, _lockroot is true, parent is _level0 +Child: level is _level0.child3, root is _level0.child3, _lockroot is true, parent is _level0 +Child: level is _level0.child1.child1, root is _level0, _lockroot is false, parent is _level0.child1 +Child: level is _level0.child1.child2, root is _level0.child1.child2, _lockroot is true, parent is _level0.child1 +Child: level is _level0.child1.child3, root is _level0.child1.child3, _lockroot is true, parent is _level0.child1 +Child: level is _level0.child2.child1, root is _level0.child2, _lockroot is false, parent is _level0.child2 +Child: level is _level0.child2.child2, root is _level0.child2.child2, _lockroot is true, parent is _level0.child2 +Child: level is _level0.child2.child3, root is _level0.child2.child3, _lockroot is true, parent is _level0.child2 +Child: level is _level0.child3.child1, root is _level0.child3, _lockroot is false, parent is _level0.child3 +Child: level is _level0.child3.child2, root is _level0.child3.child2, _lockroot is true, parent is _level0.child3 +Child: level is _level0.child3.child3, root is _level0.child3.child3, _lockroot is true, parent is _level0.child3 +All tests done. diff --git a/core/tests/swfs/avm1/movieclip_lockroot/test.as b/core/tests/swfs/avm1/movieclip_lockroot/test.as new file mode 100644 index 000000000..6fc07b15a --- /dev/null +++ b/core/tests/swfs/avm1/movieclip_lockroot/test.as @@ -0,0 +1,122 @@ +var levels = 1; + +function testSet(value) { + var valueLabel = typeof value == "string" ? "\"" + value + "\"" : value; + this._lockroot = false; + this._lockroot = value; + if (this._lockroot) { + trace("Parent: setting _lockroot to " + valueLabel + " sets it to true."); + this._lockroot = false; + return; + } + this._lockroot = true; + this._lockroot = value; + if (!this._lockroot) { + trace("Parent: setting _lockroot to " + valueLabel + " sets it to false."); + return; + } + + this._lockroot = false; + trace("Parent: setting _lockroot to " + valueLabel + " has no effect."); +} + +function testSelf() { + // Prints _level0, _level0, false + trace("Parent: level is " + this + ", root is " + _root + ", _lockroot is " + this._lockroot); + + // Edge case tests + testSet(true); /// true + testSet(false); // false + testSet(undefined); //false + testSet(null); // false + testSet(NaN); // false + testSet(-1); // true + testSet(0); // false + testSet(1); // true + testSet(1337); // true + testSet("true"); // true + testSet("false"); // true + testSet("foo"); // true + testSet(""); // false + testSet("0"); // true + testSet({}); // true +} + +function testChildren() { + // 1 = normal child, lockroot unset + // 2 = lockroot set on container before loading (must inherit) + // 3 = lockroot set by child function + + // Top + createEmptyMovieClip("child1", levels++); + child1.loadMovie("child.swf"); + createEmptyMovieClip("child2", levels++); + child2._lockroot = true; + child2.loadMovie("child.swf"); + createEmptyMovieClip("child3", levels++); + child3.loadMovie("child.swf"); + + // Wait for initial loads + setTimeout(createGrandChildren, 50); + + // Test it all + setTimeout(testAllChildren, 250); +} + +function createGrandChildren() { + // Each grandchild + _root.child1.createEmptyMovieClip("child1", levels++); + _root.child1.child1.loadMovie("child.swf"); + _root.child1.createEmptyMovieClip("child2", levels++); + _root.child1.child2._lockroot = true; + _root.child1.child2.loadMovie("child.swf"); + _root.child1.createEmptyMovieClip("child3", levels++); + _root.child1.child3.loadMovie("child.swf"); + + _root.child2.createEmptyMovieClip("child1", levels++); + _root.child2.child1.loadMovie("child.swf"); + _root.child2.createEmptyMovieClip("child2", levels++); + _root.child2.child2._lockroot = true; + _root.child2.child2.loadMovie("child.swf"); + _root.child2.createEmptyMovieClip("child3", levels++); + _root.child2.child3.loadMovie("child.swf"); + + _root.child3.createEmptyMovieClip("child1", levels++); + _root.child3.child1.loadMovie("child.swf"); + _root.child3.createEmptyMovieClip("child2", levels++); + _root.child3.child2._lockroot = true; + _root.child3.child2.loadMovie("child.swf"); + _root.child3.createEmptyMovieClip("child3", levels++); + _root.child3.child3.loadMovie("child.swf"); +} + +function testAllChildren() { + _root.child1.test(); // Root is _level0, lockroot false + _root.child2.test(); // Root is self, lockroot true + _root.child3.setLock(true); + _root.child3.test(); // Root is self, lockroot true + + _root.child1.child1.test(); // Root is _level0, lockroot false + _root.child1.child2.test(); // Root is self, lockroot true + _root.child1.child3.setLock(true); + _root.child1.child3.test(); // Root is self, lockroot true + + _root.child2.child1.test(); // Root is _parent, lockroot true + _root.child2.child2.test(); // Root is self, lockroot true + _root.child2.child3.setLock(true); + _root.child2.child3.test(); // Root is self, lockroot true + + _root.child3.child1.test(); // Root is _parent, lockroot true + _root.child3.child2.test(); // Root is self, lockroot true + _root.child3.child3.setLock(true); + _root.child3.child3.test(); // Root is self, lockroot true + + trace("All tests done."); +} + +function test() { + testSelf(); + testChildren(); +} + +test(); \ No newline at end of file diff --git a/core/tests/swfs/avm1/movieclip_lockroot/test.fla b/core/tests/swfs/avm1/movieclip_lockroot/test.fla new file mode 100644 index 000000000..2e0857d35 Binary files /dev/null and b/core/tests/swfs/avm1/movieclip_lockroot/test.fla differ diff --git a/core/tests/swfs/avm1/movieclip_lockroot/test.swf b/core/tests/swfs/avm1/movieclip_lockroot/test.swf new file mode 100644 index 000000000..166825627 Binary files /dev/null and b/core/tests/swfs/avm1/movieclip_lockroot/test.swf differ