first ideas for nodejs implementation
This commit is contained in:
parent
7850b0eaa9
commit
9b04a90b53
8 changed files with 610 additions and 26 deletions
|
@ -5,7 +5,7 @@
|
|||
<title>Title</title>
|
||||
|
||||
<script src="../browser.js"></script>
|
||||
<script src="index.js" defer></script>
|
||||
<script src="main.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
Initial page
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const Mimicry = require("../node");
|
||||
|
||||
test();
|
||||
function test () {
|
||||
if (!Mimicry) {
|
||||
|
@ -12,8 +14,11 @@ function test () {
|
|||
|
||||
let mimicry;
|
||||
try {
|
||||
mimicry = new Mimicry();
|
||||
window.mimicry = mimicry;
|
||||
mimicry = new Mimicry({
|
||||
baseUrl: "test"
|
||||
});
|
||||
global.mimicry = mimicry;
|
||||
global.Mimicry = Mimicry;
|
||||
log("Mimicry was successfully instantiated");
|
||||
} catch (e) {
|
||||
log("Error instantiating Mimicry");
|
||||
|
@ -37,8 +42,5 @@ function test () {
|
|||
}
|
||||
|
||||
function log (message) {
|
||||
const node = document.createTextNode(message);
|
||||
const br = document.createElement("br");
|
||||
document.body.appendChild(node);
|
||||
document.body.appendChild(br);
|
||||
console.log(message);
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
|
||||
<script src="../browser.js" data-main="index.js"></script>
|
||||
<script src="../browser.js" data-main="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Initial page
|
||||
|
|
44
test/main.js
Normal file
44
test/main.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
"use strict";
|
||||
|
||||
test();
|
||||
function test () {
|
||||
if (!Mimicry) {
|
||||
log("Mimicry class was not loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
log("Mimicry class is loaded");
|
||||
log("Mimicry ready: " + Mimicry.ready);
|
||||
|
||||
let mimicry;
|
||||
try {
|
||||
mimicry = new Mimicry();
|
||||
window.mimicry = mimicry;
|
||||
log("Mimicry was successfully instantiated");
|
||||
} catch (e) {
|
||||
log("Error instantiating Mimicry");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mimicry.module(["module"], function (global, [module]) {
|
||||
log("Mimicry empty module successfully resolved");
|
||||
log("The background now is supposed to be bluish if you're testing in browser")
|
||||
if (module === true)
|
||||
log("Value returned from additional module is correct");
|
||||
else
|
||||
log("Value returned from additional module is \"" + module + "\", which is incorrect");
|
||||
});
|
||||
log("Successfully launched Mimicry empty module");
|
||||
} catch (e) {
|
||||
log("Error launching Mimicry empty module");
|
||||
//return;
|
||||
}
|
||||
}
|
||||
|
||||
function log (message) {
|
||||
const node = document.createTextNode(message);
|
||||
const br = document.createElement("br");
|
||||
document.body.appendChild(node);
|
||||
document.body.appendChild(br);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue