
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
taco-simulate
Advanced tools
A browser based plugin simulation tool to aid development and testing of Cordova applications.
A browser based plugin simulation tool to aid development and testing of Cordova applications.
npm install -g taco-simulate
From the command line anywhere within a Cordova project, enter the following:
simulate [<platform>] [--target=<browser>]
Where:
browser.chrome, chromium, edge, firefox, ie, opera, safari. Defaults to chrome.You can also require('taco-simulate') and launch a simulation via the API:
var simulate = require('taco-simulate');
simulate(opts);
Where opts is an object with the following properties (all optional):
browser.chrome, chromium, edge, firefox, ie, opera, safari. Defaults to chrome.8000.Running the simulate command will launch your app in the browser, and open a second browser window displaying UI (the simulation host), that allows you to configure how plugins in your app respond.
This preview version currently includes built-in support for the following Cordova plugins:
It also allows for plugins to define their own UI. To add simulation support to a plugin, follow these steps:
taco-simulate-server git repository (git clone https://github.com/microsoft/taco-simulate-server.git), as it contains useful example code (see src/plugins).src/simulation. Follow the file naming conventions seen in the built-in plugins.In your plugin project, add a simulation folder under src, then add any of the following files:
sim-host-panels.html
sim-host-dialogs.html
sim-host.js
sim-host-handlers.js
app-host.js
app-host-handlers.js
app-host-clobbers.js
sim-host-panels.html
This defines panels that will appear in the simulation host UI. At the top level, it should contain one or more
cordova-panel elements. The cordova-panel element should have an id which is unique to the plugin (so the plugin
name is one possibility, or the shortened version for common plugins (like just camera instead of
cordova-plugin-camera). It should also have a caption attribute which defines the caption of the panel.
The contents of the cordova-panel element can be regular HTML, or the various custom elements which are supported
(see the existing plugin files for more details).
This file shouldn't contain any JavaScript (including inline event handlers), nor should it link any JavaScript files.
Any JavaScript required can be provided in the standard JavaScript files described below, or in additional JavaScript
files that can be included using require().
sim-host-dialogs.html
This defines any dialogs that will be used (dialogs are simple modal popups � such as used for the Camera plugin). At
the top level it should contain one or more cordova-dialog elements. Each of these must have id and caption
attributes (as for sim-host-panels.html). The id will be used in calls to dialog.showDialog() and
dialog.hideDialog() (see [taco-simulate-server/src/plugins/cordova-plugin-camera/sim-host.js]
(https://github.com/Microsoft/taco-simulate-server/blob/master/src/plugins/cordova-plugin-camera/sim-host.js)
for example code).
Other rules for this file are the same as for sim-host-panels.html.
sim-host.js
This file should contain code to initialize your UI. For example � attach event handlers, populate lists etc. It should
set module.exports to one of the following:
initialize method, like this:module.exports = {
initialize: function () {
// Your initialization code here.
}
};
initialize method. This function will be passed a single parameter �
messages � which is a plugin messaging object that can be used to communicate between sim-host and app-host.
This form is used when the plugin requires that messages object � otherwise the simple form can be used. For example:module.exports = function (messages) {
return {
initialize: function () {
// Your initialization code here.
}
};
};
In both cases, the code currently executes in the context of the overall simulation host HTML document. You can use
getElementById() or querySelector() etc to reference elements in your panel to attach events etc. In the future,
this will change and there will be a well defined, limited, asynchronous API for manipulating elements in your
simulation UI.
sim-host-handlers.js
This file defines handlers for plugin exec calls. It should return an object in the following form:
{
service1: {
action1: function (success, error, args) {
// exec handler
},
action2: function (success, error, args) {
// exec handler
}
},
service2: {
action1: function (success, error, args) {
// exec handler
},
action2: function (success, error, args) {
// exec handler
}
}
}
It can define handlers for any number of service/action combinations. As for sim-host.js, it can return the object
either by;
app-host.js
This file is injected into the app itself (as part of a single, combined, app-host.js file). Typically, it would
contain code to respond to messages from sim-host code, and as such module.exports should be set a function that
takes a single messages parameter. It doesn't need to return anything.
app-host-handlers.js
This file is to provide app-host side handling of exec calls (if an exec call is handled on the app-host side,
then it doesn't need to be handled on the sim-host side, and in fact any sim-host handler will be ignored). The
format is the same as sim-host-handlers.js.
app-host-clobbers.js
This file provides support for "clobbering" built in JavaScript objects. It's form is similar to app-host-handlers.js,
expect that the returned object defines what you are clobbering. For example, the built-in support for the geolocation
plugin uses this to support simulating geolocation even when the plugin isn't present in the app (just like Ripple
does), by returning the following:
{
navigator: {
geolocation: {
getCurrentPosition: function (successCallback, errorCallback, options) {
// Blah blah blah
},
watchPosition: function (successCallback, errorCallback, options) {
// Blah blah blah
}
}
}
}
A messages object is provided to all standard JavaScript files on both the app-host and sim-host side of things.
It provides the following methods:
messages.call(method, param1, param2 ...): Calls a method implemented on "the other side" (that were registered by
calling messages.register()) and returns a promise for the return value, that is fulfilled when the method returns.
messages.register(method, handler): Registers a method handler, which can be called via messages.call().
messages.emit(message, data): Emits a message with data (scalar value or JavaScript object) which will be received by
any code that registers for it (in both app-host and sim-host).
messages.on(message, handler): Register interest in a particular message.
messages.off(message, handler): Un-register interest in a particular message.
Note that:
app-host to sim-host or vice versa (that is, a call from app-host can only be
handled by a method registered on sim-host, and vice versa).FAQs
A browser based plugin simulation tool to aid development and testing of Cordova applications.
We found that taco-simulate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.