Merged shu.hml into the inspector.

This commit is contained in:
Michael Bebenita 2012-06-29 18:33:52 -07:00
Родитель 15a071a734
Коммит 462730fd21
2 изменённых файлов: 158 добавлений и 231 удалений

Просмотреть файл

@ -10,21 +10,23 @@
}
body {
margin: 0;
font-family: Sans-Serif;
font: 11px/18px "Lucida Grande","Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif
}
#stage {
position: absolute;
top: 0; left: 0;
bottom: 38px; right: 0;
bottom: 38px; right: 0px;
}
#inputBar {
position: absolute;
bottom: 0; left: 0; right: 0;
height: 28px;
padding: 4px;
padding: 8px;
color: white !important;
background-color: #3F003F;
border-top: 2px solid black;
background: -moz-linear-gradient(top, #595959 0%, #2b2b2b 100%); /* FF3.6+ */
background: -webkit-linear-gradient(top, #595959 0%,#2b2b2b 100%); /* Chrome10+,Safari5.1+ */
}
#inputBar a {
color: white;
@ -35,12 +37,31 @@
<div id="stage"></div>
<script src="jquery.min.js"></script>
<script src="../../lib/DataView.js/DataView.js"></script>
<!-- Load SWF Dependencies -->
<script src="../../src/swf/util.js"></script>
<script src="../../src/swf/swf.js"></script>
<script src="../../src/swf/types.js"></script>
<script src="../../src/swf/structs.js"></script>
<script src="../../src/swf/tags.js"></script>
<script src="../../src/swf/inflate.js"></script>
<script src="../../src/swf/stream.js"></script>
<script src="../../src/swf/templates.js"></script>
<script src="../../src/swf/generator.js"></script>
<script src="../../src/swf/parser.js"></script>
<script src="../../src/swf/bitmap.js"></script>
<script src="../../src/swf/button.js"></script>
<script src="../../src/swf/font.js"></script>
<script src="../../src/swf/image.js"></script>
<script src="../../src/swf/label.js"></script>
<script src="../../src/swf/shape.js"></script>
<script src="../../src/swf/text.js"></script>
<script src="../../src/swf/prototypes.js"></script>
<!-- Load AVM1 Dependencies -->
<script src="../../src/avm1/classes.js"></script>
<script src="../../src/avm1/globals.js"></script>
<script src="../../src/avm1/stream.js"></script>
@ -48,16 +69,32 @@
<script src="../../src/swf/embed.js"></script>
<script src="../../src/swf/renderer.js"></script>
<script>
window.print = function (msg) {
console.log(msg);
};
var webShell = true;
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return unescape(pair[1]);
}
}
return undefined;
}
</script>
<!-- Load AVM2 Dependencies -->
<script src="../../src/avm2/util.js"></script>
<script src="../../src/avm2/options.js"></script>
<script src="../../src/avm2/metrics.js"></script>
<script>
var Timer = metrics.Timer;
var Option = options.Option;
var OptionSet = options.OptionSet;
var systemOptions = new OptionSet("System Options");
@ -67,41 +104,18 @@
<script src="../../src/avm2/constants.js"></script>
<script src="../../src/avm2/opcodes.js"></script>
<script src="../../src/avm2/parser.js"></script>
<script src="../../src/avm2/disassembler.js"></script>
<script src="../../src/avm2/analyze.js"></script>
<script src="../../src/avm2/metrics.js"></script>
<script>
var Timer = metrics.Timer;
</script>
<script src="../../src/avm2/compiler/lljs/src/estransform.js"></script>
<script src="../../src/avm2/compiler/lljs/src/escodegen.js"></script>
<script src="../../src/avm2/compiler/compiler.js"></script>
<script src="../../src/avm2/domain.js"></script>
<script src="../../src/avm2/native.js"></script>
<script src="../../src/avm2/runtime.js"></script>
<script src="../../src/avm2/disassembler.js"></script>
<script src="../../src/avm2/interpreter.js"></script>
<script src="../../src/avm2/vm.js"></script>
<script>
var abcFiles = [];
var filesLoaded = 0;
["builtin.abc"].forEach(function (v, i, a) {
var xhr = new XMLHttpRequest;
xhr.open("GET", "../../src/avm2/generated/" + v);
xhr.responseType = "arraybuffer";
xhr.onload = function () {
abcFiles[i] = new AbcFile(new Uint8Array(this.response), v, true);
if (++filesLoaded === a.length) {
abcFiles.forEach(function (abc) {
(filesLoaded === 1 ? executeAbc : loadAbc)(abc, ALWAYS_INTERPRET);
});
}
}
xhr.send();
});
</script>
<!-- Load Flash Dependencies -->
<script src="../../src/flash/util.js"></script>
<script src="../../src/flash/events/EventPhase.js"></script>
@ -125,9 +139,8 @@
</script>
<div id="inputBar">
<span><a href="https://www.github.com/mozilla/shumway">shumway</a> inspector &nbsp;&nbsp;|&nbsp;&nbsp;</span>
<label for="file">Select SWF file: </label><input type="file" id="files" name="files[]" multiple>
<span>(or drag'n'drop the file on the stage)</span>
<span><a href="https://www.github.com/mozilla/shumway">Shumway</a> Inspector</span>&nbsp;&nbsp;
<label for="file">Select SWF/ABC file (or drag'n'drop the file on the stage): </label><input type="file" id="files" name="files[]" multiple>
</div>
<script>
@ -157,5 +170,116 @@
readFile(file);
});
</script>
<script>
var BinaryFileReader = (function binaryFileReader() {
function constructor(url, responseType) {
this.url = url;
this.responseType = responseType || "arraybuffer";
}
constructor.prototype = {
readAll: function(progress, complete) {
var xhr = new XMLHttpRequest();
var async = true;
xhr.open("GET", this.url, async);
xhr.responseType = this.responseType;
if (progress) {
xhr.onprogress = function(event) {
progress(xhr.response, event.loaded, event.total);
};
}
xhr.onreadystatechange = function(event) {
if (xhr.readyState === 4) {
complete(xhr.response);
}
}
xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); // no-cache
xhr.send(null);
}
};
return constructor;
})();
var avm2Root = "../../src/avm2/"
function runAVM2(file) {
var avm2;
var loadPlayerGlobal = true;
var queue = [];
/**
* Chain together a bunch of I/O callbacks to intialize AVM2.
*/
queue.push(function () {
new BinaryFileReader(avm2Root + "generated/builtin.abc").readAll(null, function (buffer) {
avm2 = new AVM2(new Uint8Array(buffer), ALWAYS_INTERPRET);
executeNext();
});
});
if (loadPlayerGlobal) {
queue.push(function () {
new BinaryFileReader(avm2Root + "generated/playerGlobal.swf").readAll(null, function (buffer) {
avm2.loadPlayerGlobal(new Uint8Array(buffer));
executeNext();
});
});
}
// TODO: This needs to be hooked in the Loader somewhere.
if (file.endsWith(".swf")) {
queue.push(function() {
new BinaryFileReader(file).readAll(null, function(buffer) {
SWF.parse(new Uint8Array(buffer), {
oncomplete: function(result) {
var tags = result.tags;
for (var i = 0, n = tags.length; i < n; i++) {
var tag = tags[i];
if (tag.type === "abc") {
avm2.applicationDomain.loadAbc(new AbcFile(tag.data, "playerGlobal/library" + i + ".abc"));
} else if (tag.type === "symbols") {
for (var j = tag.references.length - 1; j >= 0; j--) {
if (tag.references[j].id === 0) {
avm2.applicationDomain.getProperty(
Multiname.fromSimpleName(tag.references[j].name),
true, true
);
break;
}
}
}
}
}
});
executeNext();
});
});
} else {
queue.push(function () {
new BinaryFileReader(file).readAll(null, function (buffer) {
avm2.applicationDomain.executeAbc(new AbcFile(new Uint8Array(buffer), file, true));
executeNext();
});
});
}
function executeNext() {
if (queue.length === 0) {
return;
}
queue.shift()();
}
executeNext();
}
var file = getQueryVariable("file");
if (file) {
runAVM2(file || avm2Root + "tests/watch.swf");
}
</script>
</body>
</html>

Просмотреть файл

@ -1,197 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Shumway Web Shell</title>
</head>
<body>
<script type="text/javascript">
print = function(message) {
console.log(message);
};
var webShell = true;
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return unescape(pair[1]);
}
}
return undefined;
}
</script>
<script>
var SWF = {};
</script>
<script type="text/javascript" src="../../swf/util.js"></script>
<script type="text/javascript" src="../../swf/types.js"></script>
<script type="text/javascript" src="../../swf/structs.js"></script>
<script type="text/javascript" src="../../swf/tags.js"></script>
<script type="text/javascript" src="../../swf/inflate.js"></script>
<script type="text/javascript" src="../../swf/stream.js"></script>
<script type="text/javascript" src="../../swf/templates.js"></script>
<script type="text/javascript" src="../../swf/generator.js"></script>
<script type="text/javascript" src="../../swf/parser.js"></script>
<script type="text/javascript" src="../../swf/bitmap.js"></script>
<script type="text/javascript" src="../../swf/button.js"></script>
<script type="text/javascript" src="../../swf/font.js"></script>
<script type="text/javascript" src="../../swf/image.js"></script>
<script type="text/javascript" src="../../swf/label.js"></script>
<script type="text/javascript" src="../../swf/shape.js"></script>
<script type="text/javascript" src="../../swf/text.js"></script>
<script type="text/javascript" src="../util.js"></script>
<script type="text/javascript" src="../metrics.js"></script>
<script type="text/javascript" src="../options.js"></script>
<script>
var Timer = metrics.Timer;
var Option = options.Option;
var OptionSet = options.OptionSet;
var systemOptions = new OptionSet("System Options");
var disassemble = systemOptions.register(new Option("d", "disassemble", "boolean", false, "disassemble"));
</script>
<script src="../../../lib/DataView.js/DataView.js"></script>
<script type="text/javascript" src="../constants.js"></script>
<script type="text/javascript" src="../opcodes.js"></script>
<script type="text/javascript" src="../parser.js"></script>
<script type="text/javascript" src="../analyze.js"></script>
<script type="text/javascript" src="../viz.js"></script>
<script type="text/javascript" src="../compiler/lljs/src/estransform.js"></script>
<script type="text/javascript" src="../compiler/lljs/src/escodegen.js"></script>
<script type="text/javascript" src="../compiler/compiler.js"></script>
<script type="text/javascript" src="../native.js"></script>
<script type="text/javascript" src="../domain.js"></script>
<script type="text/javascript" src="../runtime.js"></script>
<script type="text/javascript" src="../disassembler.js"></script>
<script type="text/javascript" src="../interpreter.js"></script>
<script type="text/javascript">
var FileReader = (function fileReader() {
function constructor(url, responseType) {
this.url = url;
this.responseType = responseType || "arraybuffer";
}
constructor.prototype = {
readAll: function(progress, complete) {
var xhr = new XMLHttpRequest();
var async = true;
xhr.open("GET", this.url, async);
xhr.responseType = this.responseType;
if (progress) {
xhr.onprogress = function(event) {
progress(xhr.response, event.loaded, event.total);
};
}
xhr.onreadystatechange = function(event) {
if (xhr.readyState === 4) {
complete(xhr.response);
}
}
xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); // no-cache
xhr.send(null);
}
};
return constructor;
})();
</script>
<script type="text/javascript">
var sysDomain = new Domain(null, ALWAYS_INTERPRET, true);
var loadPlayerGlobal = true;
var file = getQueryVariable("file") || "../tests/watch.swf";
var queue = [];
/**
* Chains together a bunch of I/O callbacks to intialize the sys and app domains.
*/
queue.push(function () {
new FileReader("../generated/builtin.abc").readAll(null, function (buffer) {
sysDomain.executeAbc(new AbcFile(new Uint8Array(buffer), "builtin.abc", true));
executeNext();
});
});
if (loadPlayerGlobal) {
queue.push(function () {
new FileReader("../generated/playerGlobal.swf").readAll(null, function (buffer) {
SWF.parse(buffer, {
oncomplete: function(result) {
var tags = result.tags;
for (var i = 0, n = tags.length; i < n; i++) {
var tag = tags[i];
if (tag.type === "abc") {
sysDomain.loadAbc(new AbcFile(tag.data, "playerGlobal/library" + i + ".abc"));
}
}
}
});
executeNext();
});
});
}
var appDomain = new Domain(sysDomain, ALWAYS_INTERPRET, false);
if (file.endsWith(".swf")) {
queue.push(function() {
new FileReader(file).readAll(null, function(buffer) {
SWF.parse(buffer, {
oncomplete: function(result) {
var tags = result.tags;
for (var i = 0, n = tags.length; i < n; i++) {
var tag = tags[i];
if (tag.type === "abc") {
appDomain.loadAbc(new AbcFile(tag.data, "playerGlobal/library" + i + ".abc"));
} else if (tag.type === "symbols") {
for (var j = tag.references.length - 1; j >= 0; j--) {
if (tag.references[j].id === 0) {
appDomain.getProperty(
Multiname.fromSimpleName(tag.references[j].name),
true, true
);
break;
}
}
}
}
}
});
executeNext();
});
});
} else {
queue.push(function () {
new FileReader(file).readAll(null, function (buffer) {
sysDomain.executeAbc(new AbcFile(new Uint8Array(buffer), file, true));
executeNext();
});
});
}
function executeNext() {
if (queue.length === 0) {
return;
}
queue.shift()();
}
executeNext();
</script>
</body>
</html>