I am developing a windows 8 application. After generating a page on the app (I copied the code from win js (http://try.buildwinjs.com/#listview:gridlayout)) always an error occurs:
terminateAppHandler [base.js] Line 9357 Script
The code that generates this error is:
var terminateAppHandler = function (data) {
debugger;
MSApp.terminateApp(data);
};
I don't know what is meaning of the error it self, however with other pages which also use win js doenst happen.
Any idea why?
Related
So I'm trying to run javascript code on website through my WebBrowser in console application but I came across weird bug. This is my code:
object[] mathArgs = { "javascript:setTimeout('__doPostBack(\'someID\',\'\')', 0)" };
mainWebBrowser.Document.InvokeScript("eval", mathArgs);
and after this I receive:
"There was an error in the script on this page:
Line: 1
Char: 1
Expected char ')'
Code: 0"
Funny thing is it works well in WinForms project, there is problem in console app. Am I missing something? Additionally, it's code that works on page I work on.
If your code work without any problem use the "ScriptErrorsSuppressed" property to ignore JS errors :
WebBrowser mainWebBrowser = new WebBrowser {ScriptErrorsSuppressed = true};
// Navigation code gose here
object[] mathArgs = { "javascript:setTimeout('__doPostBack(\'someID\',\'\')', 0)" };
mainWebBrowser?.Document?.InvokeScript("eval", mathArgs);
So I'm using a library called ng-webworker and attempting to run a very simple long running task.
$scope.onParallelDownload = function() {
function doubler(num) {
return num * 2;
}
var myWorker = webWorker.create(doubler);
myWorker.run(3).then(function(result) {
alert("Answer: " + result);
}, function(error) {
var err = error;
});
}
This works perfectly in Chrome and shows the alert, but when run in Internet Explorer 11, where I am debugging it the error function is hit, which was still promising, however, there is no data given in the error payload which is problematic because I've absolutely no idea what is causing the web worker to fail on that particular browser.
Most likely you did not set the path to the file worker_wrapper.min.js (or worker_wrapper.js). This file is required for IE (see below). Adjust your app config to the following:
angular.module('myApp', [
// your dependencies
'ngWebworker'
])
.config(['WebworkerProvider', function (WebworkerProvider) {
WebworkerProvider.setHelperPath("./bower_components/ng-webworker/src/worker_wrapper.min.js"); // adjust path
}]);
This code assumes you installed ngWebworker with bower. You might still have to adjust the path, depending on the path you are in.
If you've already set the helper path but it still does not work, check if helper file is being loaded in the developer tools (you might have set a wrong path and get a 404).
Details
When passing a function to Webworker, it transforms this function into a blob which is then executed by the web worker as if it were an independent file. However, Internet Explorer treats these blobs as cross-domain, so this does not work. The workaround that ngWebworker uses is to run an independent JavaScript file (the worker_wrapper.min.js we set above). The web worker then runs that file and ngWebworker passes your stringified function to the worker where it is evaluated.
Note that if you're not on IE, this file will not be used.
I am getting an error which seems to be originating from one of the page scripts.
file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1
return c.apply(undefined,a)}catch(d){webengage.eLog(d);if(!b){throw d}}}else{t
^
TypeError: Cannot call method 'call' of undefined
at new exports.NOT_IMPLEMENTED (/usr/local/lib/node_modules/jsdom/lib/jsdom/browser/utils.js:9:13)
at Object.webengage.eLog (file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1:366)
at t.extend.u (file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1:19160)
at Object.t.extend.error (file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1:19299)
at file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1:66518
at Object.webengage.withELog (file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1:640)
at Timer.<anonymous> (file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1:937)
at Timer.exports.setInterval.timer.ontimeout (timers.js:234:14)
I am getting this error from the following code:
try {
var document = jsdom.jsdom(str, null, {});
} catch(e) {
console.log("Got ERROR...");
console.log(e);
}
console.log("Page Document Loaded.");
var window = document.parentWindow;
//console.log(window.document.innerHTML);
console.log(window.innerWidth);
console.log(typeof window.document.getElementsByClassName);
here str is the html that i got earlier. I am able to see printed results, the html the innerWidth and the typeof getElementsByClassName i.e.. function. But after around 20 seconds i am getting the above error and my application crashes, without printing Got ERROR... from above.
The first question that i have is why is my application still running after printing the last thing. Is this a normal behavior for jsdom that it keeps on running like how in a browser a script keeps on running until window.close() is given.
The actual problem is, how can i resolve this. I want to trigger few events in this window object and interact with it but it keeps on crashing.
The url for the script is a little confusing:
file://cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1
this is because the page is fetching this script resource in an ajax call with the url:
//cdn.widgets.webengage.com/js/widget/webengage-min-v-3.0.js:1
although jsdom is able to get the resource, i checked that this script has that line where it is showing the error.
My add-on creates a FireFox File menu command that triggers callback function 'launchApp'.
function launchApp() {
var ww = Cc["#mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
var appUrl='chrome://mrT2/mrT00.xul'; // production (fails)
var appUrl='file:///C:/mpa/##mrT-2.0/mrT00.xul'; // testing (works)
var win = ww.openWindow(null, appUrl, "mrT2-window", "chrome,resizable", null);
// Summary of results of ww.openWindow() for various appUrl values:
// 'chrome:///mrT2/mrT00.xul' 'No chrome package registered for ...' (true)
// 'chrome://mrT00.xul' 'Invalid chrome URI: /' (true)
// 'chrome:///mrT00.xul' and 'chrome://mrT2/mrT00.xul' seem valid yet both give:
//Error: NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 ...
// ... (NS_ERROR_ILLEGAL_VALUE) [nsIWindowWatcher.openWindow] (unexplained)
return true;
The above code works nicely and is great for testing mrT00.xul (because it collects the file directly from where I am editing it).
However when I interchange the two appUrl vars to try and open the exact same file as shipped via the xpi (and now internal to firefox) I get the dreaded 'illegal value' 0x80070057.
After 2 long days of research and study I cannot fault my code. Can you?
Otherwise, how may I begin tracing nsiWindowWatcher to pinpoint the error?
Bad things can happen when an extension attempts to open a xul file outside the /content directory or inside it when the chrome.manifest file in the .xpi root is not in order. Firefox handling of both these situations is not above reproach, warnings being offered in neither case.
LOG:
Runtime Installer begin with version 3.3.0.3650 on Mac OS 10.7.4 x86
Commandline is: -updatecheck
Installed runtime (3.3.0.3650) located at /Library/Frameworks/Adobe AIR.framework
Performing pingback request
Failure during pingback request: [ErrorEvent type="error" bubbles=false cancelable=falsr eventPhase=2 text="Unhandled exception Error: Error #3001" errorID=3001]
Runtime Installer end with exit code 0
It works fine on Windows but fails for Mac.
Digging around I found out that the error code #3001 has something to do with file/directory permission issues.
Checked /Users/internetslave/Library/Application Support/Adobe permissions seems ok. source.
Checked /Library/Frameworks/Adobe AIR.framework seems ok too.
Both had drwxr-xr-x.
UPDATE: permission is not an issue, successfully updated other applications on the same system.
var appUpdater;
function checkForUpdates() {
appUpdater = new air.ApplicationUpdaterUI();
appUpdater.configurationFile = new air.File("app:/update/update-config.xml");
appUpdater.addEventListener(air.ErrorEvent.ERROR, onCheckForUpdatesError);
appUpdater.initialize();
setTimeout(function() {
appUpdater.checkNow();
}, 500);
}
function onCheckForUpdatesError(event) {
alert(event.toString());
}
Cant seem to post the update configuration and descriptor files here.
For those might stumble upon the same problem.
The problem was the ApplicationUpdaterUI has not finished initializing when the method checkNow is called.
So either, change the second parameter of the setTimeout to a higher value or place this part
appUpdater = new air.ApplicationUpdaterUI();
appUpdater.configurationFile = new air.File("app:/update/update-config.xml");
appUpdater.addEventListener(air.ErrorEvent.ERROR, onCheckForUpdatesError);
appUpdater.initialize();
in page onLoad event handler and attach the checkNow method to a button onClick event
function checkUpdates() {
appUpdater.checkNow();
}
<input type="button" onclick="checkUpdates()" />
Thanks!