This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
forked from Siv3D/OpenSiv3D
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
27 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,16 @@ | ||
// | ||
// Mock implementation for Node.js | ||
// | ||
|
||
Module.preRun = [ | ||
function () | ||
// Test stub: throw JSException instead of abort. | ||
Module["onAbort"] = function(e) { | ||
if ((e !== "" && e !== "native code called abort()")) | ||
{ | ||
FS.mkdir('/test'); | ||
FS.mount(NODEFS, { root: '../../../Test/test' }, '/test'); | ||
|
||
FS.mkdir('/resources'); | ||
FS.mount(NODEFS, { root: '../../App/resources' }, '/resources'); | ||
|
||
// | ||
// Mock Implementations | ||
// | ||
global.navigator = { | ||
getGamepads() { return []; } | ||
}; | ||
|
||
global.window = { | ||
alert(text) { console.error(text); }, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
speechSynthesis: { | ||
getVoices() { return []; } | ||
}, | ||
screen: {} | ||
}; | ||
|
||
global.document = { | ||
createElement() { | ||
return { | ||
style: {}, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
}; | ||
}, | ||
}; | ||
|
||
Module.canvas = { | ||
style: { | ||
removeProperty() {} | ||
}, | ||
parentNode: { | ||
prepend() {} | ||
}, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
}; | ||
|
||
global.FileReader = class { | ||
constructor() {} | ||
}; | ||
|
||
global.Notification = { | ||
permission: "granted", | ||
requestPermission() {} | ||
}; | ||
|
||
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; | ||
Module["siv3dSetThrowJSException"](e); | ||
} | ||
|
||
global.requestAnimationFrame = function(callback) { | ||
setTimeout(callback, 16); | ||
}; | ||
if (e === -1) { | ||
// FIXME: -1 is thrown when unresolved function is called in emscripten 3.1.20. | ||
// We should migrate to emscripten 3.1.53, in which unresolved symbol report will be thrown. | ||
// | ||
// abort(-1); // emscripten 3.1.20, not user friendly abort | ||
// abort("missing function: <some function name>"); // emscripten 3.1.53 | ||
Module["siv3dSetThrowJSException"](e.toString()); | ||
} | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters