Skip to content

Commit

Permalink
tests: Add avm2/sandbox_type_remote test
Browse files Browse the repository at this point in the history
Verifies the sandbox type of SWFs loaded through network.
  • Loading branch information
kjarosh committed Sep 13, 2024
1 parent f77dddb commit acdb355
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/tests/swfs/avm2/sandbox_type_remote/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.system.Security;
import flash.net.URLRequest;

// Compile with network enabled
public class Test extends MovieClip {
public function Test() {
trace("Current sandbox type: " + Security.sandboxType);

var test:Test = this;
test.loadSwf("http://localhost:8000/test-network.swf", function():void {
test.loadSwf("http://localhost:8000/test-no-network.swf", function():void {});
});
}

private function loadSwf(url:String, callback:Function):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener("complete", callback);
loader.load(new URLRequest(url));
}
}
}
11 changes: 11 additions & 0 deletions tests/tests/swfs/avm2/sandbox_type_remote/TestNetwork.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package {
import flash.display.Sprite;
import flash.system.Security;

// Compile with network enabled as localhost/test-network.swf
public class TestNetwork extends Sprite {
public function TestNetwork() {
trace("[Network] Current sandbox type: " + Security.sandboxType);
}
}
}
11 changes: 11 additions & 0 deletions tests/tests/swfs/avm2/sandbox_type_remote/TestNoNetwork.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package {
import flash.display.Sprite;
import flash.system.Security;

// Compile with network disabled as localhost/test-no-network.swf
public class TestNoNetwork extends Sprite {
public function TestNoNetwork() {
trace("[No network] Current sandbox type: " + Security.sandboxType);
}
}
}
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/tests/swfs/avm2/sandbox_type_remote/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Current sandbox type: localWithNetwork
[Network] Current sandbox type: remote
[No network] Current sandbox type: remote
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/sandbox_type_remote/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 2

0 comments on commit acdb355

Please sign in to comment.