The simplest way is to run the action. If it throws an exception, check to see if it's the exception for a missing action.
document = app.open(new File(inputFile));
try {
app.doAction(actionToRun, actionSetToRun);
} catch (e) {
// Check e to see if it's the missing action exception.
}
Or you can use this function extracted from xtools/xlib/stdlib.js.
function hasAction(atn, atnSet) {
function cTID(s) { return app.charIDToTypeID(s); };
var asetDesc;
var rc = false;
var i = 1;
var asMatches = [];
while (true) {
var ref = new ActionReference();
ref.putIndex(cTID("ASet"), i);
var desc;
try {
desc = executeActionGet(ref);
} catch (e) {
break; // all done
}
if (desc.hasKey(cTID("Nm ")) &&
desc.getString(cTID("Nm ")) == atnSet) {
asetDesc = desc;
asMatches.push({ index: i, desc: desc});
//break;
}
i++;
}
if (asMatches.length == 0) {
return false;
}
for (var i = 0; i < asMatches.length; i++) {
var asmatch = asMatches;
var asetIndex = asmatch.index;
asetDesc = asmatch.desc;
if (!asetDesc.hasKey(cTID("NmbC"))) {
continue;
}
var max = asetDesc.getInteger(cTID("NmbC"));
for (var j = 1; j <= max; j++) {
var ref = new ActionReference();
ref.putIndex(cTID("Actn"), j); // Action index
ref.putIndex(cTID("ASet"), asetIndex); // ActionSet index
var desc;
try {
desc = executeActionGet(ref);
} catch (e) {
break; // all done
}
if (desc.hasKey(cTID("Nm ")) &&
desc.getString(cTID("Nm ")) == atn) {
return true;
}
}
}
return rc;
};