Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implementation of blackberry.app.extendTerminate and exit event

This is not working! executeJavaScript does not work to send the event to the client webview. It appears WebKit completely kills the webview as soon as the exit event occurs. Extend terminate is working from within the controller.

Issue #393
  • Loading branch information...
commit fb591e799dd3e285f8eb7c75bef4f927ba024619 1 parent 32c8c38
@bryanhiggins bryanhiggins authored
View
4 ext/app/client.js
@@ -21,6 +21,10 @@ _self.exit = function () {
return window.webworks.execSync(ID, "exit");
};
+_self.extendTerminate = function () {
+ return window.webworks.execSync(ID, "extendTerminate");
+};
+
function getReadOnlyFields() {
if (!readOnlyValues) {
readOnlyValues = window.webworks.execSync(ID, "getReadOnlyFields", null);
View
12 ext/app/index.js
@@ -40,6 +40,13 @@ var _config = require("./../../lib/config"),
_event.trigger("resume");
}
},
+ exit: {
+ context: _appEvents,
+ event: "exit",
+ trigger: function () {
+ _event.trigger("exit");
+ }
+ },
keyboardOpening: {
context: _appEvents,
event: "keyboardOpening",
@@ -211,6 +218,11 @@ module.exports = {
success(orientation);
},
+ extendTerminate: function (success) {
+ window.qnx.webplatform.getApplication().extendTerminate();
+ success();
+ },
+
exit: function () {
window.qnx.webplatform.getApplication().exit();
}
View
1  lib/event.js
@@ -22,6 +22,7 @@ module.exports = {
//Change arguments into a real array instead of a fake one
var args = Array.prototype.slice.call(arguments);
//Send all the arguments as JSON
+ console.log("webworks.event.trigger('" + name + "', '" + encodeURIComponent(JSON.stringify(args.slice(1))) + "')");
_webview.executeJavascript("webworks.event.trigger('" + name + "', '" + encodeURIComponent(JSON.stringify(args.slice(1))) + "')");
},
View
8 lib/framework.js
@@ -98,6 +98,14 @@ var _self = {
};
}
});
+
+ //extend terminate once to give client webview chance to handle exit event
+ qnx.webplatform.getApplication().addEventListener('application.exit', function () {
+// while(true) {
+ qnx.webplatform.getApplication().extendTerminate();
+ //console.log('EXITING>>>>>>>>');
+ // }
+ });
},
{
debugEnabled : config.debugEnabled
View
4 test/test-app/config.xml
@@ -20,7 +20,7 @@
<feature id="blackberry.app" required="true" version="1.0.0.0">
<param name="backgroundColor" value="0xFFFFEFD5" />
</feature>
- <feature id="blackberry.system" required="true" version="1.0.0.0"/>
+<!-- <feature id="blackberry.system" required="true" version="1.0.0.0"/>
<feature id="blackberry.connection" required="true" version="1.0.0.0"/>
<feature id="blackberry.identity" required="true" version="1.0.0.0"/>
<feature id="blackberry.event" required="true" version="1.0.0.0"/>
@@ -168,5 +168,5 @@
<rim:permit>post_notification</rim:permit>
<rim:permit system="true">_sys_use_consumer_push</rim:permit>
<rim:permit>run_when_backgrounded</rim:permit>
- </rim:permissions>
+ </rim:permissions>-->
</widget>
View
23 test/test-app/manual/framework-split/exit.htm
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>blackberry.invoke.card manual tests</title>
+</head>
+<script src="local:///chrome/webworks.js" type="text/javascript"></script>
+<body>
+
+ <script type="text/javascript">
+ document.addEventListener("webworksready", function () {
+ blackberry.event.addEventListener("exit", function () {
+ while(true) {
+ console.log("EXITNG FROM CLIENT WEBVIEW");
+ }
+ });
+ alert(blackberry.app.extendTerminate);
+ });
+ </script>
+ <input type="button" value="console.log" onclick="console.log(blackberry.app.extendTerminate);" />
+ <input type="button" value="Back" onclick="history.back()" />
+</body>
+</html>
View
4 test/test-app/manual/framework-split/main.htm
@@ -14,6 +14,9 @@
function do_mediaplayer_Test() {
document.location.href = "local:///manual/framework-split/mediaplayer.htm";
}
+ function do_exit_Test() {
+ document.location.href = "local:///manual/framework-split/exit.htm";
+ }
</script>
</head>
<body>
@@ -29,5 +32,6 @@
<p>
<input id="Button17" type="button" value="mediaplayer" onclick="return do_mediaplayer_Test()" /></p>
</ol>
+ <input type="button" value="exit" onclick="return do_exit_Test()" />
</body>
</html>
View
8 test/unit/ext/app/client.js
@@ -188,4 +188,12 @@ describe("app client", function () {
expect(mockedWebworks.execSync).toHaveBeenCalledWith(_ID, "rotate", {orientation: 'landscape'});
});
});
+
+ describe("extendTerminate", function () {
+ it("should call execSync", function () {
+ client.extendTerminate();
+ expect(mockedWebworks.execSync).toHaveBeenCalledWith(_ID, "extendTerminate");
+ });
+ });
+
});
View
12 test/unit/ext/app/index.js
@@ -19,6 +19,7 @@ var _apiDir = __dirname + "./../../../../ext/app/",
eventExt = require(__dirname + "./../../../../ext/event/index"),
index,
mockedExit,
+ mockedExtendTerminate,
mockedRotate,
mockedLockRotation,
mockedUnlockRotation,
@@ -72,6 +73,7 @@ describe("app index", function () {
config = require(_libDir + "config");
index = require(_apiDir + "index");
mockedExit = jasmine.createSpy("exit");
+ mockedExtendTerminate = jasmine.createSpy("mockedExit");
mockedRotate = jasmine.createSpy();
mockedLockRotation = jasmine.createSpy();
mockedUnlockRotation = jasmine.createSpy();
@@ -81,6 +83,7 @@ describe("app index", function () {
getApplication: function () {
return {
exit: mockedExit,
+ extendTerminate: mockedExtendTerminate,
rotate: mockedRotate,
lockRotation: mockedLockRotation,
unlockRotation: mockedUnlockRotation
@@ -94,6 +97,7 @@ describe("app index", function () {
config = null;
index = null;
mockedExit = null;
+ mockedExtendTerminate = null;
mockedRotate = null;
mockedLockRotation = null;
mockedUnlockRotation = null;
@@ -210,6 +214,14 @@ describe("app index", function () {
});
});
+ describe("extendTerminate", function () {
+ it("can call extendTerminate on the qnx.weblplatform Application", function () {
+ var success = jasmine.createSpy();
+ index.extendTerminate(success);
+ expect(mockedExtendTerminate).toHaveBeenCalled();
+ });
+ });
+
describe("events", function () {
beforeEach(function () {
spyOn(events, "add");
Please sign in to comment.
Something went wrong with that request. Please try again.