Skip to content

Commit

Permalink
tests: Add tests from Dinnerbone
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Jun 3, 2024
1 parent 690a280 commit 35ec0b9
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 0 deletions.
81 changes: 81 additions & 0 deletions tests/tests/swfs/avm2/xml_namespace_methods/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package {
import flash.display.MovieClip;
import flash.xml.XMLNode;


public class Test extends MovieClip {


public function Test() {
XML.prettyPrinting = false;

var xml: XML =
<root>
<outer>
<top xmlns:topns="https://example.org/top" topns:test="top with topns">
<middle xmlns:middlens="https://example.org/middle" topns:test="middle with topns">
<bottom xmlns:bottomns="https://example.org/bottom" topns:test="bottom with topns" bottomns:test="bottom with bottomns"/>
<topns:namespacedTopnsSibling />
<middlens:namespacedMiddlensSibling />
</middle>
</top>
</outer>
</root>;

dump(xml);

trace("");
trace("top.addNamespace(new Namespace(\"topns\", \"https://example.org/top/but/replaced\"))");
xml.outer[0].top[0].addNamespace(new Namespace("topns", "https://example.org/top/but/replaced"));
trace("top.addNamespace(new Namespace(\"middlens\", \"https://example.org/middle/but/replaced\"))");
xml.outer[0].top[0].addNamespace(new Namespace("middlens", "https://example.org/middle/but/replaced"));
trace("top.addNamespace(new Namespace(\"newns\", \"https://example.org/new\"))");
xml.outer[0].top[0].addNamespace(new Namespace("newns", "https://example.org/new"));
trace("top.addNamespace(new Namespace(undefined, \"https://example.org/undefined\"))");
xml.outer[0].top[0].addNamespace(new Namespace(undefined, "https://example.org/undefined"));

trace("");
dump(xml);
trace("");
trace("");
trace(xml.toString());
}

function dump(node: XML) {
trace("// " + node.localName() + " namespace()");
traceNs(node.namespace());
trace("");

trace("// " + node.localName() + " inScopeNamespaces()");
for each (var ns in node.inScopeNamespaces()) {
traceNs(ns);
}
trace("");

trace("// " + node.localName() + " inScopeNamespaces()");
for each (var ns in node.inScopeNamespaces()) {
traceNs(ns);
}
trace("");

trace("// " + node.localName() + " namespaceDeclarations()");
for each (var ns in node.namespaceDeclarations()) {
traceNs(ns);
}
trace("");

trace("// " + node.localName() + " namespace(\"middlens\")");
trace(node.namespace("middlens"));
trace("");

for each (var child in node.children()) {
dump(child);
}
}

function traceNs(ns: Namespace) {
trace(ns.prefix + " = " + ns.uri);
}
}

}
245 changes: 245 additions & 0 deletions tests/tests/swfs/avm2/xml_namespace_methods/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// root namespace()
=

// root inScopeNamespaces()
=

// root inScopeNamespaces()
=

// root namespaceDeclarations()

// root namespace("middlens")
undefined

// outer namespace()
=

// outer inScopeNamespaces()
=

// outer inScopeNamespaces()
=

// outer namespaceDeclarations()

// outer namespace("middlens")
undefined

// top namespace()
=

// top inScopeNamespaces()
topns = https://example.org/top

// top inScopeNamespaces()
topns = https://example.org/top

// top namespaceDeclarations()
topns = https://example.org/top

// top namespace("middlens")
undefined

// middle namespace()
=

// middle inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top

// middle inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top

// middle namespaceDeclarations()
middlens = https://example.org/middle

// middle namespace("middlens")
https://example.org/middle

// bottom namespace()
=

// bottom inScopeNamespaces()
bottomns = https://example.org/bottom
middlens = https://example.org/middle
topns = https://example.org/top

// bottom inScopeNamespaces()
bottomns = https://example.org/bottom
middlens = https://example.org/middle
topns = https://example.org/top

// bottom namespaceDeclarations()
bottomns = https://example.org/bottom

// bottom namespace("middlens")
https://example.org/middle

// namespacedTopnsSibling namespace()
topns = https://example.org/top

// namespacedTopnsSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top

// namespacedTopnsSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top

// namespacedTopnsSibling namespaceDeclarations()

// namespacedTopnsSibling namespace("middlens")
https://example.org/middle

// namespacedMiddlensSibling namespace()
middlens = https://example.org/middle

// namespacedMiddlensSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top

// namespacedMiddlensSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top

// namespacedMiddlensSibling namespaceDeclarations()

// namespacedMiddlensSibling namespace("middlens")
https://example.org/middle


top.addNamespace(new Namespace("topns", "https://example.org/top/but/replaced"))
top.addNamespace(new Namespace("middlens", "https://example.org/middle/but/replaced"))
top.addNamespace(new Namespace("newns", "https://example.org/new"))
top.addNamespace(new Namespace(undefined, "https://example.org/undefined"))

// root namespace()
=

// root inScopeNamespaces()
=

// root inScopeNamespaces()
=

// root namespaceDeclarations()

// root namespace("middlens")
undefined

// outer namespace()
=

// outer inScopeNamespaces()
=

// outer inScopeNamespaces()
=

// outer namespaceDeclarations()

// outer namespace("middlens")
undefined

// top namespace()
=

// top inScopeNamespaces()
topns = https://example.org/top/but/replaced
middlens = https://example.org/middle/but/replaced
newns = https://example.org/new

// top inScopeNamespaces()
topns = https://example.org/top/but/replaced
middlens = https://example.org/middle/but/replaced
newns = https://example.org/new

// top namespaceDeclarations()
topns = https://example.org/top/but/replaced
middlens = https://example.org/middle/but/replaced
newns = https://example.org/new

// top namespace("middlens")
https://example.org/middle/but/replaced

// middle namespace()
=

// middle inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// middle inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// middle namespaceDeclarations()
middlens = https://example.org/middle

// middle namespace("middlens")
https://example.org/middle

// bottom namespace()
=

// bottom inScopeNamespaces()
bottomns = https://example.org/bottom
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// bottom inScopeNamespaces()
bottomns = https://example.org/bottom
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// bottom namespaceDeclarations()
bottomns = https://example.org/bottom

// bottom namespace("middlens")
https://example.org/middle

// namespacedTopnsSibling namespace()
undefined = https://example.org/top

// namespacedTopnsSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// namespacedTopnsSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// namespacedTopnsSibling namespaceDeclarations()

// namespacedTopnsSibling namespace("middlens")
https://example.org/middle

// namespacedMiddlensSibling namespace()
middlens = https://example.org/middle

// namespacedMiddlensSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// namespacedMiddlensSibling inScopeNamespaces()
middlens = https://example.org/middle
topns = https://example.org/top/but/replaced
newns = https://example.org/new

// namespacedMiddlensSibling namespaceDeclarations()

// namespacedMiddlensSibling namespace("middlens")
https://example.org/middle



<root><outer><top test="top with topns" xmlns:topns="https://example.org/top/but/replaced" xmlns:middlens="https://example.org/middle/but/replaced" xmlns:newns="https://example.org/new" xmlns="https://example.org/top"><middle test="middle with topns" xmlns:middlens="https://example.org/middle"><bottom test="bottom with topns" bottomns:test="bottom with bottomns" xmlns:bottomns="https://example.org/bottom"/><namespacedTopnsSibling/><middlens:namespacedMiddlensSibling/></middle></top></outer></root>
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/xml_namespace_methods/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_frames = 1

0 comments on commit 35ec0b9

Please sign in to comment.