Merge pull request #4 from tinyhippos/next
Code Pull for ripple 0.6.0
diff --git a/Jakefile b/Jakefile
index d668dde..1cfd6c6 100644
--- a/Jakefile
+++ b/Jakefile
@@ -23,8 +23,8 @@
task('deploy', [], require('./build/deploy'));
desc("run all tests in node with an emulated dom - jake test [path,path2]");
-task('test', [], function (custom) {
- require('./build/test')(null, custom);
+task('test', [], function () {
+ require('./build/test')(null, process.argv.length >= 4 ? process.argv[3] : null);
});
desc("boot test server for running all tests in the browser");
diff --git a/build/btest/test.html b/build/btest/test.html
index 8726032..be017e6 100644
--- a/build/btest/test.html
+++ b/build/btest/test.html
@@ -82,7 +82,6 @@
<script src="thirdparty/browser-require/require.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/Math.uuid.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.js" type="text/javascript" charset="utf-8"></script>
- <script src="thirdparty/aop.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.ui.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.dimensions.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.tooltip.js" type="text/javascript" charset="utf-8"></script>
diff --git a/build/test.js b/build/test.js
index 30c74bb..57239e3 100644
--- a/build/test.js
+++ b/build/test.js
@@ -46,8 +46,7 @@
layout = fs.readFileSync(__dirname + "/../ext/assets/index.html", "utf-8"),
thirdparty = [
__dirname + "/../thirdparty/jquery.js",
- __dirname + "/../thirdparty/jquery.ui.js",
- __dirname + "/../thirdparty/aop.js"
+ __dirname + "/../thirdparty/jquery.ui.js"
];
jsdom.env(layout, thirdparty, function (error, window) {
diff --git a/ext/assets/images/Torch.png b/ext/assets/images/Torch.png
index 6ea0f0e..66ca0fb 100644
--- a/ext/assets/images/Torch.png
+++ b/ext/assets/images/Torch.png
Binary files differ
diff --git a/ext/assets/images/Torch_landscape.png b/ext/assets/images/Torch_landscape.png
index 9c6e6d4..2fdb991 100644
--- a/ext/assets/images/Torch_landscape.png
+++ b/ext/assets/images/Torch_landscape.png
Binary files differ
diff --git a/ext/chromium/controllers/Insertion.js b/ext/chromium/controllers/Insertion.js
index f42ef05..8e56dbe 100644
--- a/ext/chromium/controllers/Insertion.js
+++ b/ext/chromium/controllers/Insertion.js
@@ -16,12 +16,13 @@
(function () {
function _subscribeToEnableDisable() {
chrome.extension.onRequest.addListener(function (request, sender, sendResponse) {
- switch (request.action)
- {
+ var uri = location.href;
+ switch (request.action) {
case "enable":
break;
case "disable":
localStorage.removeItem("tinyhippos-enabled-uri");
+ uri = uri.toLowerCase().replace("?enableripple=true", "").replace("&enableripple=true", "");
break;
default:
@@ -29,7 +30,7 @@
}
sendResponse({});
- location.assign(location.href);
+ location.assign(uri);
});
}
diff --git a/lib/ripple.js b/lib/ripple.js
index 0ca07d0..2417d28 100644
--- a/lib/ripple.js
+++ b/lib/ripple.js
@@ -36,7 +36,6 @@
.andThen(devices.initialize, devices)
.andThen(platform.initialize, platform)
.andThen(widgetConfig.initialize, widgetConfig)
- .andThen(platform.inject, platform)
.andThen(deviceSettings.initialize, deviceSettings)
.andThen(ui.initialize, ui)
.start(booted);
diff --git a/lib/ripple/console.js b/lib/ripple/console.js
index 31a83cc..f85a4c2 100644
--- a/lib/ripple/console.js
+++ b/lib/ripple/console.js
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+var _self;
+
function _log(msg, method) {
try {
- console[method](msg);
+ console[method](_self.prefix ? _self.prefix + " :: " + msg : msg);
} catch (e) {
// silent
}
}
-module.exports = {
+_self = {
log: function (msg) {
_log(msg, "log");
},
@@ -32,9 +34,7 @@
error: function (msg) {
_log(msg, "error");
- },
-
- clear: function () {
- console.clear();
}
};
+
+module.exports = _self;
diff --git a/lib/ripple/devices/Torch/skin.css b/lib/ripple/devices/Torch/skin.css
index bc0d47c..480a9c4 100644
--- a/lib/ripple/devices/Torch/skin.css
+++ b/lib/ripple/devices/Torch/skin.css
@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/* ------------------------------>
- Torch Skin (446x782) offset (41x144)*/
+ Torch Skin (444x779) offset (40x142)*/
.viewport-wrapper-Torch {
width:360px;
height:480px;
@@ -23,9 +24,9 @@
.device-wrapper-Torch {
position: relative;
- padding: 144px 0 0 41px;
- width:405px;
- height:638px;
+ padding: 142px 0 0 40px;
+ width:404px;
+ height:637px;
margin: 0 auto;
border: none;
-webkit-box-shadow: none;
@@ -35,7 +36,7 @@
.menu-button-wrapper-Torch {
position: relative;
display: inline-block;
- margin: 30px 0 0 75px;
+ margin: 32px 0 0 75px;
width: 55px;
height: 65px;
cursor: pointer;
@@ -44,14 +45,14 @@
.back-button-wrapper-Torch {
position: relative;
display: inline-block;
- margin: 0 0 0 95px;
+ margin: 0 0 0 92px;
width: 55px;
height: 65px;
cursor: pointer;
}
.viewport-wrapper-landscape-Torch {
- margin: -99px 0 0 104px;
+ margin: -99px 0 0 103px;
width:480px;
height:360px;
border: none;
@@ -60,9 +61,9 @@
.device-wrapper-landscape-Torch {
position: relative;
- padding: 144px 0 0 41px;
- width:740px;
- height:300px;
+ padding: 142px 0 0 40px;
+ width:739px;
+ height:302px;
margin: 0 auto;
border: none;
-webkit-box-shadow: none;
@@ -86,3 +87,4 @@
height: 65px;
cursor: pointer;
}
+
diff --git a/lib/ripple/emulatorBridge.js b/lib/ripple/emulatorBridge.js
index 4a234dc..6704de7 100644
--- a/lib/ripple/emulatorBridge.js
+++ b/lib/ripple/emulatorBridge.js
@@ -15,6 +15,7 @@
*/
var _isMouseDown = false,
platform = require('ripple/platform'),
+ builder = require('ripple/platform/builder'),
constants = require('ripple/constants'),
utils = require('ripple/utils'),
exception = require('ripple/exception'),
@@ -72,12 +73,16 @@
_frame = frame;
var marshal = function (obj, key) {
- window[key] = _frame.contentWindow[key] = obj;
- };
+ window[key] = _frame.contentWindow[key] = obj;
+ },
+ sandbox = {};
marshal(window.tinyHippos, "tinyHippos");
marshal(window.XMLHttpRequest, "XMLHttpRequest");
- utils.forEach(platform.sandbox, marshal);
+
+ builder.build(platform.current().objects).into(sandbox);
+
+ utils.forEach(sandbox, marshal);
_marshalScreen(_frame.contentWindow);
_marshalScreen(window);
diff --git a/lib/ripple/fileSystem.js b/lib/ripple/fileSystem.js
index fca10c4..d6cc3a1 100644
--- a/lib/ripple/fileSystem.js
+++ b/lib/ripple/fileSystem.js
@@ -77,7 +77,7 @@
}
catch (e) {
exception.handle(e);
- _console.log("Emulator :: failed to check if [" + path + "] exists");
+ _console.log("failed to check if [" + path + "] exists");
return false;
}
},
diff --git a/lib/ripple/platform.js b/lib/ripple/platform.js
index ef56d33..dba3fd4 100644
--- a/lib/ripple/platform.js
+++ b/lib/ripple/platform.js
@@ -20,8 +20,7 @@
constants = require('ripple/constants'),
app = require('ripple/app'),
event = require('ripple/event'),
- builder = require('ripple/platform/builder'),
- spec,
+ spec = require('ripple/platform/spec'),
_self;
function _checkForDeprecatedPlatforms(replacement) {
@@ -39,10 +38,7 @@
}
_self = {
- sandbox: {},
-
initialize: function () {
- spec = require('ripple/platform/spec');
var firstAvailablePlatform = utils.map(this.getList(), function (platform) {
return utils.map(platform, function (details, version) {
return {name: details.id, version: version};
@@ -56,10 +52,8 @@
} else {
_current = firstAvailablePlatform;
}
- },
- inject: function () {
- builder.build(_getPlatform().objects).into(_self.sandbox);
+ _console.prefix = _getPlatform().name;
},
getList: function () {
@@ -101,6 +95,7 @@
db.save(constants.ENCAPSULATOR.LAYOUT, null, null, baton.pass);
}).andThen(function () {
event.trigger("PlatformChangedEvent", true);
+ _console.prefix = null;
_console.log("Emulator :: loading platform " + platform.name);
});
diff --git a/lib/ripple/platform/opera/4.0/widget.js b/lib/ripple/platform/opera/4.0/widget.js
index 10d3d20..e4817bb 100644
--- a/lib/ripple/platform/opera/4.0/widget.js
+++ b/lib/ripple/platform/opera/4.0/widget.js
@@ -25,7 +25,7 @@
event.on("ScreenChangeDimensions", function (width, height) {
var eventToFire = document.createEvent("Event");
- _console.log(platform.current().name + " :: Firing resolution changed event for width: " + width + " and height: " + height);
+ _console.log("Firing resolution changed event for width: " + width + " and height: " + height);
eventToFire.height = height;
eventToFire.width = width;
eventToFire.initEvent("resolution", false, false);
@@ -61,7 +61,7 @@
utils.validateNumberOfArguments(1, 2, arguments.length);
utils.validateArgumentType(key, "string");
- var msg = platform.current().name + " :: ",
+ var msg = "",
prefix = platform.getPersistencePrefix();
if (app.isPreferenceReadOnly(key)) {
@@ -90,7 +90,7 @@
var prefix = platform.getPersistencePrefix(),
value = db.retrieve(key, prefix) || undefined;
- _console.log(platform.current().name + " :: retrieving preference " + key + " == " + value);
+ _console.log("retrieving preference " + key + " == " + value);
return value;
},
@@ -116,13 +116,13 @@
},
addEventListener: function (type, expression, bubbling) {
- _console.log(platform.current().name + " :: Adding Widget Event Listener for type == " + type);
+ _console.log("Adding Widget Event Listener for type == " + type);
bubbling = bubbling || false;
window.addEventListener(type, expression, bubbling);
},
removeEventListener: function (type, listener, useCapture) {
- _console.log(platform.current().name + " :: Removing a Widget Event Listener for type == " + type);
+ _console.log("Removing a Widget Event Listener for type == " + type);
window.removeEventListener(type, listener, useCapture);
}
};
diff --git a/lib/ripple/platform/phonegap/0.9/navigator.js b/lib/ripple/platform/phonegap/0.9/navigator.js
index 3d7ce12..589c3a2 100644
--- a/lib/ripple/platform/phonegap/0.9/navigator.js
+++ b/lib/ripple/platform/phonegap/0.9/navigator.js
@@ -18,7 +18,6 @@
_console = require('ripple/console'),
utils = require('ripple/utils'),
emulatorBridge = require('ripple/emulatorBridge'),
- platform = require('ripple/platform'),
_self = {};
event.on("TinyHipposLoaded", function () {
@@ -26,7 +25,7 @@
evt = doc.createEvent("Events");
evt.initEvent("deviceready", true, true);
doc.dispatchEvent(evt);
- _console.log(platform.current().name + " :: fired deviceready event!");
+ _console.log("fired deviceready event!");
});
utils.mixin(nav, _self);
diff --git a/lib/ripple/platform/phonegap/0.9/notification.js b/lib/ripple/platform/phonegap/0.9/notification.js
index 65ff978..47ad9bb 100644
--- a/lib/ripple/platform/phonegap/0.9/notification.js
+++ b/lib/ripple/platform/phonegap/0.9/notification.js
@@ -17,8 +17,7 @@
constants = require('ripple/constants'),
_console = require('ripple/console'),
ui = require('ripple/ui'),
- goodVibrations = require('ripple/ui/plugins/goodVibrations'),
- platform = require('ripple/platform');
+ goodVibrations = require('ripple/ui/plugins/goodVibrations');
module.exports = {
alert: function (message, title, buttonName) {
@@ -27,7 +26,7 @@
beep: function (times) {
for (var i = times; i > 0; i--) {
- _console.log(platform.current().name + " :: beep!");
+ _console.log("beep!");
}
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, "BEEP x " + times);
},
diff --git a/lib/ripple/platform/w3c/1.0/geolocation.js b/lib/ripple/platform/w3c/1.0/geolocation.js
index 6cb8579..24c373a 100644
--- a/lib/ripple/platform/w3c/1.0/geolocation.js
+++ b/lib/ripple/platform/w3c/1.0/geolocation.js
@@ -28,6 +28,7 @@
_positionInfo.coords.longitude = positionInfo.longitude;
_positionInfo.coords.altitude = positionInfo.altitude;
_positionInfo.coords.altitudeAccuracy = positionInfo.altitudeAccuracy;
+ _positionInfo.coords.accuracy = positionInfo.accuracy;
_positionInfo.coords.heading = positionInfo.heading;
_positionInfo.coords.speed = positionInfo.speed;
_positionInfo.timestamp = positionInfo.timeStamp.getTime();
@@ -59,7 +60,6 @@
var watchId = (new Date()).getTime().toString(),
watchObj = {};
-
if (geolocationOptions &&
geolocationOptions.frequency && typeof
geolocationOptions.frequency === "number" &&
diff --git a/lib/ripple/platform/wac/1.0/AudioPlayer.js b/lib/ripple/platform/wac/1.0/AudioPlayer.js
index 41942fc..d4a8078 100644
--- a/lib/ripple/platform/wac/1.0/AudioPlayer.js
+++ b/lib/ripple/platform/wac/1.0/AudioPlayer.js
@@ -15,7 +15,6 @@
*/
var constants = require('ripple/constants'),
event = require('ripple/event'),
- platform = require('ripple/platform'),
exception = require('ripple/exception'),
utils = require('ripple/utils'),
fileSystem = require('ripple/fileSystem'),
@@ -40,9 +39,9 @@
});
_audio.addEventListener('error', function () {
- _console.warn(platform.current().name + " :: AudioPlayer encountered an error: " + _audio.error.code);
+ _console.warn("AudioPlayer encountered an error: " + _audio.error.code);
if (_audio.error.code === 4) {
- _console.warn(platform.current().name + " :: AudioPlayer error 4 could be caused by missing codecs");
+ _console.warn("AudioPlayer error 4 could be caused by missing codecs");
}
_state = null;
event.trigger("MultimediaAudioStateChanged", [null], true);
@@ -68,8 +67,7 @@
}
if (!valid) {
- _console.warn(platform.current().name +
- " :: Attempted to initiate AudioPlayer." + state +
+ _console.warn("Attempted to initiate AudioPlayer." + state +
" in invalid state. current state: " + _state);
} else {
if (typeof(callbackBeforeSuccess) === "function") {
@@ -86,8 +84,7 @@
type = matched ? matched[1] : "";
if (_audio && _audio.canPlayType("audio/" + type) === "") {
- _console.warn(platform.current().name +
- " :: Attempting to load an audio that might not work in the current browser [" + fileUrl + "]");
+ _console.warn("Attempting to load an audio that might not work in the current browser [" + fileUrl + "]");
}
}
diff --git a/lib/ripple/platform/wac/1.0/Camera.js b/lib/ripple/platform/wac/1.0/Camera.js
index 621abc2..0fc6fa7 100644
--- a/lib/ripple/platform/wac/1.0/Camera.js
+++ b/lib/ripple/platform/wac/1.0/Camera.js
@@ -19,7 +19,6 @@
constants = require('ripple/constants'),
_console = require('ripple/console'),
utils = require('ripple/utils'),
- platform = require('ripple/platform'),
notifications = require('ripple/notifications'),
_currentlySet,
_img,
@@ -78,7 +77,7 @@
var msg = constants.CAMERA.WARNING_TEXT;
msg = msg.replace("{file}", fileName);
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, msg);
- _console.log(platform.current().name + " :: simulated saved image as: " + fileName);
+ _console.log("simulated saved image as: " + fileName);
if (_self.onCameraCaptured) {
_self.onCameraCaptured.apply(_self, [fileName]);
}
@@ -106,7 +105,7 @@
['string', 'boolean', 'integer', 'boolean'],
ExceptionTypes.INVALID_PARAMETER,
"invalid parameter type", new Exception());
- _console.log(platform.current().name + " :: started recording video");
+ _console.log("started recording video");
var interval = window.setTimeout(function () {
_self.stopVideoCapture();
}, maxDurationSeconds * 1000);
@@ -133,7 +132,7 @@
stopVideoCapture: function () {
utils.validateNumberOfArguments(0, 0, arguments.length, ExceptionTypes.INVALID_PARAMETER, "stopVideoCapture invalid number of parameters", new Exception());
if (_videoCapture) {
- _console.log(platform.current().name + " :: simulated saving a video as: " + _videoCapture.fileName);
+ _console.log("simulated saving a video as: " + _videoCapture.fileName);
if (_buttons) {
_buttons.setAttribute("style", "display: none");
}
diff --git a/lib/ripple/platform/wac/1.0/DataNetworkInfo.js b/lib/ripple/platform/wac/1.0/DataNetworkInfo.js
index f4cd799..cf86d0b 100644
--- a/lib/ripple/platform/wac/1.0/DataNetworkInfo.js
+++ b/lib/ripple/platform/wac/1.0/DataNetworkInfo.js
@@ -14,7 +14,6 @@
* limitations under the License.
*/
var event = require('ripple/event'),
- platform = require('ripple/platform'),
utils = require('ripple/utils'),
_console = require('ripple/console'),
deviceSettings = require('ripple/deviceSettings'),
@@ -37,7 +36,7 @@
event.on("DataNetworkConnectionChanged", function (newConnectionName) {
var callback = _self.onNetworkConnectionChanged,
- msg = platform.current().name + " :: Fired onNetworkConnectionChanged with newConnectionName: " + newConnectionName;
+ msg = "Fired onNetworkConnectionChanged with newConnectionName: " + newConnectionName;
if (callback && typeof callback === "function") {
callback.apply(null, [newConnectionName]);
diff --git a/lib/ripple/platform/wac/1.0/Device.js b/lib/ripple/platform/wac/1.0/Device.js
index c2f7fdd..da16c3c 100644
--- a/lib/ripple/platform/wac/1.0/Device.js
+++ b/lib/ripple/platform/wac/1.0/Device.js
@@ -14,9 +14,8 @@
* limitations under the License.
*/
var constants = require('ripple/constants'),
- exception = require('ripple/platform'),
+ exception = require('ripple/exception'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
utils = require('ripple/utils'),
notifications = require('ripple/notifications'),
ApplicationTypes = require('ripple/platform/wac/1.0/ApplicationTypes'),
@@ -82,7 +81,7 @@
}
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, message);
- _console.log(platform.current().name + " :: " + message);
+ _console.log(message);
},
copyFile: function () {
diff --git a/lib/ripple/platform/wac/1.0/DeviceStateInfo.js b/lib/ripple/platform/wac/1.0/DeviceStateInfo.js
index 734fc68..36a3b53 100644
--- a/lib/ripple/platform/wac/1.0/DeviceStateInfo.js
+++ b/lib/ripple/platform/wac/1.0/DeviceStateInfo.js
@@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-var platform = require('ripple/platform'),
- utils = require('ripple/utils'),
+var utils = require('ripple/utils'),
exception = require('ripple/exception'),
_console = require('ripple/console'),
geo = require('ripple/geo'),
@@ -30,7 +29,7 @@
if (typeof _self.onScreenChangeDimensions === 'function') {
_self.onScreenChangeDimensions(width, height);
}
- _console.log(platform.current().name + " :: called DeviceStateInfo.onScreenChangeDimensions callback function with width = " + width + " and height = " + height);
+ _console.log("called DeviceStateInfo.onScreenChangeDimensions callback function with width = " + width + " and height = " + height);
} catch (e) {
exception.handle(e, false);
}
@@ -106,3 +105,4 @@
});
module.exports = _self;
+
diff --git a/lib/ripple/platform/wac/1.0/Messaging.js b/lib/ripple/platform/wac/1.0/Messaging.js
index c79f829..6daa5d9 100644
--- a/lib/ripple/platform/wac/1.0/Messaging.js
+++ b/lib/ripple/platform/wac/1.0/Messaging.js
@@ -18,7 +18,6 @@
constants = require('ripple/constants'),
notifications = require('ripple/notifications'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
Message = require('ripple/platform/wac/1.0/Message'),
MessageTypes = require('ripple/platform/wac/1.0/MessageTypes'),
Exception = require('ripple/platform/wac/1.0/Exception'),
@@ -68,7 +67,7 @@
// insert fail check here
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, message);
- _console.log(platform.current().name + " :: " + message);
+ _console.log(message);
},
moveMessageToFolder: function () {
_throwUnsupportedException("Messaging.moveMessageToFolder");
diff --git a/lib/ripple/platform/wac/1.0/PowerInfo.js b/lib/ripple/platform/wac/1.0/PowerInfo.js
index 26115db..d2dfa85 100644
--- a/lib/ripple/platform/wac/1.0/PowerInfo.js
+++ b/lib/ripple/platform/wac/1.0/PowerInfo.js
@@ -16,7 +16,6 @@
var _self,
event = require('ripple/event'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
deviceSettings = require('ripple/deviceSettings'),
_lastPercentRemaining;
@@ -45,13 +44,13 @@
event.on("DeviceBatteryStateChanged", function (isCharging) {
var callback = _self.onChargeStateChange,
- msg = platform.current().name,
+ msg = "",
batteryLevel = _self.percentRemaining,
batteryState;
batteryState = _getCurrentChargeState(batteryLevel, isCharging);
- msg += " :: Fired onChargeStateChange with batteryState: " + batteryState;
+ msg += "Fired onChargeStateChange with batteryState: " + batteryState;
if (callback && typeof callback === "function") {
callback.apply(null, [batteryState]);
@@ -67,7 +66,7 @@
var callback = _self.onChargeLevelChange,
lowBatteryCallback = _self.onLowBattery,
- msg = platform.current().name + " :: Fired onChargeLevelChange with percentRemaining: " + percentRemaining;
+ msg = "Fired onChargeLevelChange with percentRemaining: " + percentRemaining;
// blah, stupid Options returning strings
percentRemaining = parseInt(percentRemaining, 10);
@@ -83,7 +82,7 @@
if (percentRemaining <= 10) {
- msg = platform.current().name + " :: Fired onLowBattery with percentRemaining: " + percentRemaining;
+ msg = "Fired onLowBattery with percentRemaining: " + percentRemaining;
if (lowBatteryCallback && typeof lowBatteryCallback === "function") {
lowBatteryCallback.apply(null, [percentRemaining]);
diff --git a/lib/ripple/platform/wac/1.0/RadioInfo.js b/lib/ripple/platform/wac/1.0/RadioInfo.js
index 654ded0..396f7ad 100644
--- a/lib/ripple/platform/wac/1.0/RadioInfo.js
+++ b/lib/ripple/platform/wac/1.0/RadioInfo.js
@@ -16,7 +16,6 @@
var _self,
event = require('ripple/event'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
deviceSettings = require('ripple/deviceSettings');
_self = {
@@ -31,7 +30,7 @@
var callback = _self.onSignalSourceChange,
isRoaming = _self.isRoaming,
signalSource = _self.radioSignalSource,
- msg = platform.current().name + " :: Fired onSignalSourceChange. signalSource: " + signalSource + ", isRoaming: " + isRoaming;
+ msg = "Fired onSignalSourceChange. signalSource: " + signalSource + ", isRoaming: " + isRoaming;
if (callback && typeof callback === "function") {
callback.apply(null, [signalSource, isRoaming]);
diff --git a/lib/ripple/platform/wac/1.0/VideoPlayer.js b/lib/ripple/platform/wac/1.0/VideoPlayer.js
index c5aeb9b..8e49424 100644
--- a/lib/ripple/platform/wac/1.0/VideoPlayer.js
+++ b/lib/ripple/platform/wac/1.0/VideoPlayer.js
@@ -15,7 +15,6 @@
*/
var _self,
_console = require('ripple/console'),
- platform = require('ripple/platform'),
event = require('ripple/event'),
utils = require('ripple/utils'),
fileSystem = require('ripple/fileSystem'),
@@ -43,8 +42,7 @@
type = matched ? matched[1] : "";
if (_video && _video.canPlayType("video/" + (maps[type] || type)) === "") {
- _console.warn(platform.current().name +
- " :: Attempting to load a video that might not work in the current browser [" + fileUrl + "]");
+ _console.warn("Attempting to load a video that might not work in the current browser [" + fileUrl + "]");
}
}
@@ -58,8 +56,7 @@
}
if (!valid) {
- _console.warn(platform.current().name +
- " :: Attempted to initiate VideoPlayer." + state +
+ _console.warn("Attempted to initiate VideoPlayer." + state +
" in invalid state. current state: " + _state);
} else {
if (typeof(callbackBeforeSuccess) === "function") {
diff --git a/lib/ripple/platform/wac/1.0/Widget.js b/lib/ripple/platform/wac/1.0/Widget.js
index a90e2a5..8cac8c6 100644
--- a/lib/ripple/platform/wac/1.0/Widget.js
+++ b/lib/ripple/platform/wac/1.0/Widget.js
@@ -33,7 +33,7 @@
if (typeof app.onRestore === 'function') {
app.onRestore();
}
- _console.log(platform.current().name + " :: called Widget.onRestore and Widget.onMaximize callback function");
+ _console.log("called Widget.onRestore and Widget.onMaximize callback function");
}
catch (e) {
exception.handle(e, false);
@@ -80,7 +80,7 @@
utils.validateArgumentType(key, "string", ExceptionTypes.INVALID_PARAMETER, "setPreferenceForKey invalid parameter! Key:" +
key + ", Value: " + value, new Exception());
- var msg = platform.current().name + " :: ",
+ var msg = "",
prefix;
if (app.isPreferenceReadOnly(key)) {
msg += "Cannot modify a read only preference. Preference key: " + key;
@@ -119,7 +119,7 @@
value = undefined;
}
- _console.log(platform.current().name + " :: retrieving preference " + key + " == " + value);
+ _console.log("retrieving preference " + key + " == " + value);
return value;
diff --git a/lib/ripple/platform/web/default/spec.js b/lib/ripple/platform/web/default/spec.js
index a442e38..a65a20e 100644
--- a/lib/ripple/platform/web/default/spec.js
+++ b/lib/ripple/platform/web/default/spec.js
@@ -18,14 +18,29 @@
id: "web",
version: "default",
name: "Mobile Web",
- ui: {},
+
+ ui: require('ripple/platform/web/default/spec/ui'),
device: {},
persistencePrefix: "tinyhippos-",
objects: {
+ Coordinates: {
+ path: "w3c/1.0/Coordinates"
+ },
+ Position: {
+ path: "w3c/1.0/Position"
+ },
+ PositionError: {
+ path: "w3c/1.0/PositionError"
+ },
navigator: {
- path: "w3c/1.0/navigator"
+ path: "w3c/1.0/navigator",
+ children: {
+ geolocation: {
+ path: "w3c/1.0/geolocation"
+ }
+ }
},
tinyHipposWeb: {
path: "web/default/tinyHipposWeb"
diff --git a/lib/ripple/platform/web/default/spec/ui.js b/lib/ripple/platform/web/default/spec/ui.js
new file mode 100644
index 0000000..30e4052
--- /dev/null
+++ b/lib/ripple/platform/web/default/spec/ui.js
@@ -0,0 +1,5 @@
+module.exports = {
+ plugins: [
+ "geoView"
+ ]
+};
diff --git a/lib/ripple/platform/webworks/2.0.0/XMLHttpRequest.js b/lib/ripple/platform/webworks/2.0.0/XMLHttpRequest.js
index 265d8c0..bba4abc 100644
--- a/lib/ripple/platform/webworks/2.0.0/XMLHttpRequest.js
+++ b/lib/ripple/platform/webworks/2.0.0/XMLHttpRequest.js
@@ -113,7 +113,7 @@
var pair = param.split("="),
value;
try {
- value = JSON.parse(pair[1]);
+ value = JSON.parse(decodeURIComponent(pair[1]));
} catch (e) {
value = pair[1] === "undefined" ? undefined : pair[1];
}
diff --git a/lib/ripple/platform/webworks/2.0.0/client/Appointment.js b/lib/ripple/platform/webworks/2.0.0/client/Appointment.js
index c203739..a724300 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/Appointment.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/Appointment.js
@@ -72,7 +72,7 @@
}
};
- return transport.call(_uri + "find", opts).data.map(function (obj) {
+ return transport.call(_uri + "find", opts).map(function (obj) {
var appt = new Appointment();
appt.allDay = obj.allDay;
appt.attendees = obj.attendees;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/AudioPlayer.js b/lib/ripple/platform/webworks/2.0.0/client/AudioPlayer.js
index c674f0a..ef68a0d 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/AudioPlayer.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/AudioPlayer.js
@@ -21,7 +21,7 @@
var _id = transport.call(_uri + "create", {
get: {locator: locator, type: type},
async: false
- }).data,
+ }),
_listener,
_closed,
_self,
@@ -30,7 +30,7 @@
get: {id: _id}
}, function (response) {
if (_listener) {
- _listener(_self, response.data.event, response.data.eventData);
+ _listener(_self, response.event, response.eventData);
}
return !!_listener;
@@ -61,24 +61,24 @@
close: function () {
_listener = null;
_closed = true;
- return transport.call(_uri + "close", {get: {id: _id}}).data;
+ return transport.call(_uri + "close", {get: {id: _id}});
},
pause: function () {
- return transport.call(_uri + "pause", {get: {id: _id}}).data;
+ return transport.call(_uri + "pause", {get: {id: _id}});
},
play: function () {
- return transport.call(_uri + "play", {get: {id: _id}}).data;
+ return transport.call(_uri + "play", {get: {id: _id}});
}
};
_self.__defineGetter__("duration", function () {
- return transport.call(_uri + "getDuration", {get: {id: _id}}).data;
+ return transport.call(_uri + "getDuration", {get: {id: _id}});
});
_self.__defineGetter__("mediaTime", function () {
- return transport.call(_uri + "getMediaTime", {get: {id: _id}}).data;
+ return transport.call(_uri + "getMediaTime", {get: {id: _id}});
});
_self.__defineSetter__("mediaTime", function (val) {
@@ -86,11 +86,11 @@
});
_self.__defineGetter__("state", function () {
- return transport.call(_uri + "getState", {get: {id: _id}}).data;
+ return transport.call(_uri + "getState", {get: {id: _id}});
});
_self.__defineGetter__("volumeLevel", function () {
- return transport.call(_uri + "getVolumeLevel", {get: {id: _id}}).data;
+ return transport.call(_uri + "getVolumeLevel", {get: {id: _id}});
});
_self.__defineSetter__("volumeLevel", function (val) {
diff --git a/lib/ripple/platform/webworks/2.0.0/client/Contact.js b/lib/ripple/platform/webworks/2.0.0/client/Contact.js
index 32d357c..b1de890 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/Contact.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/Contact.js
@@ -88,7 +88,7 @@
service: service,
isAscending: isAscending
}
- }).data.map(function (properties) {
+ }).map(function (properties) {
var contact = new Contact(),
key;
for (key in properties) {
diff --git a/lib/ripple/platform/webworks/2.0.0/client/Memo.js b/lib/ripple/platform/webworks/2.0.0/client/Memo.js
index 77f0e5a..74e3bfa 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/Memo.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/Memo.js
@@ -51,7 +51,7 @@
}
};
- return transport.call(_uri + "find", opts).data.map(function (obj) {
+ return transport.call(_uri + "find", opts).map(function (obj) {
var memo = new Memo();
memo.uid = obj.uid;
memo.categories = obj.categories || [];
diff --git a/lib/ripple/platform/webworks/2.0.0/client/Message.js b/lib/ripple/platform/webworks/2.0.0/client/Message.js
index 9bad80c..8ca4be5 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/Message.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/Message.js
@@ -90,7 +90,7 @@
}
};
- return transport.call(_uri + "find", opts).data.map(function (obj) {
+ return transport.call(_uri + "find", opts).map(function (obj) {
var msg = new Message();
msg.uid = obj.uid;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/Phone.js b/lib/ripple/platform/webworks/2.0.0/client/Phone.js
index 25499c5..ea7cb18 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/Phone.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/Phone.js
@@ -20,7 +20,7 @@
_self = {
activeCalls: function () {
- return transport.call(_uri + "activeCalls").data;
+ return transport.call(_uri + "activeCalls");
},
addPhoneListener: function (callback, eventType) {
@@ -38,7 +38,7 @@
var func = _listeners[eventType];
if (func) {
- func(response.data.callId, response.data.error);
+ func(response.callId, response.error);
}
return !!func;
@@ -46,7 +46,7 @@
},
inActiveCall: function () {
- return transport.call(_uri + "inActiveCall").data;
+ return transport.call(_uri + "inActiveCall");
}
};
diff --git a/lib/ripple/platform/webworks/2.0.0/client/PhoneLogs.js b/lib/ripple/platform/webworks/2.0.0/client/PhoneLogs.js
index 2598def..56e8550 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/PhoneLogs.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/PhoneLogs.js
@@ -48,7 +48,7 @@
var func = _onCallLog[evt], args;
if (func) {
- args = utils.map(response.data, function (value) {
+ args = utils.map(response, function (value) {
return _toCallLog(value);
});
func.apply(null, args);
@@ -92,7 +92,7 @@
index: index,
folderID: folderID
}
- }).data;
+ });
if (log && log.date) {
log.date = new Date(log.date);
@@ -107,7 +107,7 @@
index: index,
folderID: folderID
}
- }).data;
+ });
},
find: function (filter, folderID, orderBy, maxReturn, isAscending) {
@@ -119,7 +119,7 @@
maxReturn: maxReturn,
isAscending: isAscending
}
- }).data.map(_toCallLog);
+ }).map(_toCallLog);
},
numberOfCalls: function (folderID) {
@@ -127,7 +127,7 @@
get: {
folderID: folderID
}
- }).data;
+ });
}
};
diff --git a/lib/ripple/platform/webworks/2.0.0/client/Task.js b/lib/ripple/platform/webworks/2.0.0/client/Task.js
index 2fad2cd..6f23b1c 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/Task.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/Task.js
@@ -77,7 +77,7 @@
maxReturn: maxReturn,
isAscending: isAscending
}
- }).data.map(function (properties) {
+ }).map(function (properties) {
var task = new Task(),
key;
for (key in properties) {
diff --git a/lib/ripple/platform/webworks/2.0.0/client/app.js b/lib/ripple/platform/webworks/2.0.0/client/app.js
index 7c9a406..6b91d75 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/app.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/app.js
@@ -53,43 +53,43 @@
};
_self.__defineGetter__("author", function () {
- return transport.call(_uri + "author").data;
+ return transport.call(_uri + "author");
});
_self.__defineGetter__("authorEmail", function () {
- return transport.call(_uri + "authorEmail").data;
+ return transport.call(_uri + "authorEmail");
});
_self.__defineGetter__("authorURL", function () {
- return transport.call(_uri + "authorURL").data;
+ return transport.call(_uri + "authorURL");
});
_self.__defineGetter__("copyright", function () {
- return transport.call(_uri + "copyright").data;
+ return transport.call(_uri + "copyright");
});
_self.__defineGetter__("description", function () {
- return transport.call(_uri + "description").data;
+ return transport.call(_uri + "description");
});
_self.__defineGetter__("id", function () {
- return transport.call(_uri + "id").data;
+ return transport.call(_uri + "id");
});
_self.__defineGetter__("license", function () {
- return transport.call(_uri + "license").data;
+ return transport.call(_uri + "license");
});
_self.__defineGetter__("licenseURL", function () {
- return transport.call(_uri + "licenseURL").data;
+ return transport.call(_uri + "licenseURL");
});
_self.__defineGetter__("name", function () {
- return transport.call(_uri + "name").data;
+ return transport.call(_uri + "name");
});
_self.__defineGetter__("version", function () {
- return transport.call(_uri + "version").data;
+ return transport.call(_uri + "version");
});
module.exports = _self;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/blackberry.js b/lib/ripple/platform/webworks/2.0.0/client/blackberry.js
index 774bae8..b8857f0 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/blackberry.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/blackberry.js
@@ -17,7 +17,7 @@
transport = require('ripple/platform/webworks/2.0.0/client/transport');
blackberry.__defineGetter__("network", function () {
- return transport.call("blackberry/system/network").data;
+ return transport.call("blackberry/system/network");
});
module.exports = blackberry;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/category.js b/lib/ripple/platform/webworks/2.0.0/client/category.js
new file mode 100644
index 0000000..798b03d
--- /dev/null
+++ b/lib/ripple/platform/webworks/2.0.0/client/category.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
+ _uri = "blackberry/pim/category/",
+ _self;
+
+_self = {
+ addCategory: function (categoryName) {
+ transport.call(_uri + "addCategory", {
+ get: {categoryName: categoryName}
+ });
+ },
+ deleteCategory: function (categoryName) {
+ transport.call(_uri + "deleteCategory", {
+ get: {categoryName: categoryName}
+ });
+ },
+ getCategories: function () {
+ return transport.call(_uri + "getCategories");
+ }
+};
+
+module.exports = _self;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/dialog.js b/lib/ripple/platform/webworks/2.0.0/client/dialog.js
index 0e3ca55..1426203 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/dialog.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/dialog.js
@@ -44,9 +44,9 @@
}
}, function (response) {
if (callback) {
- callback(response.data);
+ callback(response);
}
- }).data;
+ });
},
standardAskAsync: function (message, type, callback, settings) {
@@ -59,9 +59,9 @@
}
}, function (response) {
if (callback) {
- callback(response.data);
+ callback(response);
}
- }).data;
+ });
}
};
diff --git a/lib/ripple/platform/webworks/2.0.0/client/identity.js b/lib/ripple/platform/webworks/2.0.0/client/identity.js
index 57d84a3..2300467 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/identity.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/identity.js
@@ -19,26 +19,26 @@
_self = {
getDefaultService: function () {
- return transport.call(_uri + "getDefaultService").data;
+ return transport.call(_uri + "getDefaultService");
},
getServiceList: function () {
- return transport.call(_uri + "getServiceList").data;
+ return transport.call(_uri + "getServiceList");
},
getTransportList: function () {
- return transport.call(_uri + "getTransportList").data;
+ return transport.call(_uri + "getTransportList");
}
};
_self.__defineGetter__("IMEI", function () {
- return transport.call(_uri + "IMEI").data;
+ return transport.call(_uri + "IMEI");
});
_self.__defineGetter__("IMSI", function () {
- return transport.call(_uri + "IMSI").data;
+ return transport.call(_uri + "IMSI");
});
_self.__defineGetter__("PIN", function () {
- return transport.call(_uri + "PIN").data;
+ return transport.call(_uri + "PIN");
});
module.exports = _self;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/identity/phone.js b/lib/ripple/platform/webworks/2.0.0/client/identity/phone.js
index 21ce8e4..8283877 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/identity/phone.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/identity/phone.js
@@ -19,16 +19,16 @@
_self = {
getLineIds: function () {
- return transport.call(_uri + "getLineIds").data;
+ return transport.call(_uri + "getLineIds");
},
getLineLabel: function (id) {
- return transport.call(_uri + "getLineLabel", {get: {id: id}}).data;
+ return transport.call(_uri + "getLineLabel", {get: {id: id}});
},
getLineNumber: function (id) {
- return transport.call(_uri + "getLineNumber", {get: {id: id}}).data;
+ return transport.call(_uri + "getLineNumber", {get: {id: id}});
},
getLineType: function (id) {
- return transport.call(_uri + "getLineType", {get: {id: id}}).data;
+ return transport.call(_uri + "getLineType", {get: {id: id}});
}
};
diff --git a/lib/ripple/platform/webworks/2.0.0/client/menu.js b/lib/ripple/platform/webworks/2.0.0/client/menu.js
index 518e5c4..3b25875 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/menu.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/menu.js
@@ -30,7 +30,7 @@
if (utils.count(_items) === 1) {
transport.poll(_uri + "onSelect", {}, function (response) {
- var item = _items[response.data];
+ var item = _items[response];
if (item && item.callback) {
item.callback();
diff --git a/lib/ripple/platform/webworks/2.0.0/client/pim.js b/lib/ripple/platform/webworks/2.0.0/client/pim.js
index 9930115..d2272b6 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/pim.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/pim.js
@@ -1,6 +1,6 @@
/*
* Copyright 2011 Research In Motion Limited.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -13,24 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
- _uri = "blackberry/pim/category/",
- _self;
-
-_self = {
- addCategory: function (categoryName) {
- transport.call(_uri + "addCategory", {
- get: {categoryName: categoryName}
- });
- },
- deleteCategory: function (categoryName) {
- transport.call(_uri + "deleteCategory", {
- get: {categoryName: categoryName}
- });
- },
- getCategories: function () {
- return transport.call(_uri + "getCategories").data;
- }
-};
-
-module.exports = _self;
+module.exports = {};
diff --git a/lib/ripple/platform/webworks/2.0.0/client/push.js b/lib/ripple/platform/webworks/2.0.0/client/push.js
index 1a0ccad..ffad041 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/push.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/push.js
@@ -33,7 +33,7 @@
var func = callbacks["onPush" + port];
if (func) {
- func(new PushData(response.data, port));
+ func(new PushData(response, port));
}
return !!func;
diff --git a/lib/ripple/platform/webworks/2.0.0/client/sms.js b/lib/ripple/platform/webworks/2.0.0/client/sms.js
index 5c3d4fd..ce28802 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/sms.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/sms.js
@@ -23,7 +23,7 @@
onReceive = callback;
transport.poll(_uri + "onReceive", {}, function (response) {
if (onReceive) {
- onReceive(response.data.body, response.data.from, response.data.time);
+ onReceive(response.body, response.from, response.time);
}
return !!onReceive;
});
diff --git a/lib/ripple/platform/webworks/2.0.0/client/system.js b/lib/ripple/platform/webworks/2.0.0/client/system.js
index 7e3f3a2..3089ea7 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/system.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/system.js
@@ -21,21 +21,21 @@
hasCapability: function (capability) {
return transport.call(_uri + "hasCapability", {
get: {capability: capability}
- }).data;
+ });
},
hasDataCoverage: function () {
- return transport.call(_uri + "hasDataCoverage").data;
+ return transport.call(_uri + "hasDataCoverage");
},
hasPermission: function (desiredModule) {
return transport.call(_uri + "hasPermission", {
get: {desiredModule: desiredModule}
- }).data;
+ });
},
isMassStorageActive: function () {
- return transport.call(_uri + "isMassStorageActive").data;
+ return transport.call(_uri + "isMassStorageActive");
},
setHomeScreenBackground: function (filePath) {
@@ -47,13 +47,13 @@
};
_self.__defineGetter__("model", function () {
- return transport.call(_uri + "model").data;
+ return transport.call(_uri + "model");
});
_self.__defineGetter__("scriptApiVersion", function () {
- return transport.call(_uri + "scriptApiVersion").data;
+ return transport.call(_uri + "scriptApiVersion");
});
_self.__defineGetter__("softwareVersion", function () {
- return transport.call(_uri + "softwareVersion").data;
+ return transport.call(_uri + "softwareVersion");
});
_self.__defineGetter__("ALLOW", function () {
diff --git a/lib/ripple/platform/webworks/2.0.0/client/transport.js b/lib/ripple/platform/webworks/2.0.0/client/transport.js
index f1c308f..23b91c1 100644
--- a/lib/ripple/platform/webworks/2.0.0/client/transport.js
+++ b/lib/ripple/platform/webworks/2.0.0/client/transport.js
@@ -69,33 +69,42 @@
};
this.addPostParam = function (name, value) {
- postParams[name] = JSON.stringify(value);
+ postParams[name] = encodeURIComponent(JSON.stringify(value));
};
- this.makeSyncCall = function (callback) {
+ this.makeSyncCall = function (success, error) {
var requestUri = composeUri(),
request = createXhrRequest(requestUri, false),
- res;
+ response, errored, cb, data;
request.send(postString);
- res = JSON.parse(request.responseText || "null");
+ response = JSON.parse(request.responseText || "null");
+ errored = response.code < 0;
+ cb = errored ? error : success;
+ data = errored ? response.msg : response.data;
- if (callback) {
- callback(res);
+ if (cb) {
+ cb(data, response);
}
-
- return res;
+ else if (errored) {
+ throw data;
+ }
+
+ return data;
};
- this.makeAsyncCall = function (responseCallback) {
+ this.makeAsyncCall = function (success, error) {
var requestUri = composeUri(),
request = createXhrRequest(requestUri, true);
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
- var response = JSON.parse(request.responseText || "null");
- return responseCallback && responseCallback(response);
+ var response = JSON.parse(request.responseText || "null"),
+ cb = response.code < 0 ? error : success,
+ data = response.code < 0 ? response.msg : response.data;
+
+ return cb && cb(data, response);
}
};
@@ -104,7 +113,7 @@
}
_self = {
- call: function (url, opts, callback) {
+ call: function (url, opts, success, error) {
var request = new RemoteFunctionCall(url),
name;
@@ -126,15 +135,15 @@
}
}
- return opts.async ? request.makeAsyncCall(callback) : request.makeSyncCall(callback);
+ return opts.async ? request.makeAsyncCall(success, error) : request.makeSyncCall(success, error);
},
poll: function (url, opts, callback) {
opts = opts || {};
opts.async = true;
- _self.call(url, opts, function (response) {
- if (callback(response)) {
+ _self.call(url, opts, function (data, response) {
+ if (callback(data, response)) {
_self.poll(url, opts, callback);
}
});
diff --git a/lib/ripple/platform/webworks/2.0.0/server/contact.js b/lib/ripple/platform/webworks/2.0.0/server/contact.js
index c58eff3..27905e7 100644
--- a/lib/ripple/platform/webworks/2.0.0/server/contact.js
+++ b/lib/ripple/platform/webworks/2.0.0/server/contact.js
@@ -20,27 +20,38 @@
_self;
function _defaultContacts() {
- return [{
- uuid: Math.uuid(null, 16),
+ var id1 = Math.uuid(null, 16),
+ id2 = Math.uuid(null, 16),
+ id3 = Math.uuid(null, 16),
+ id4 = Math.uuid(null, 16),
+ contacts = {};
+
+ contacts[id1] = {
+ uuid: id1,
firstName: "Leonardo",
homePhone: "4567892345",
email1: "leo@underground.com"
- }, {
- uuid: Math.uuid(null, 16),
+ };
+ contacts[id2] = {
+ uuid: id2,
firstName: "Raphael",
homePhone: "4563457890",
email1: "raph@underground.com"
- }, {
- uuid: Math.uuid(null, 16),
+ };
+ contacts[id3] = {
+ uuid: id3,
firstName: "Michelangelo",
homePhone: "4563453425",
email1: "mike@underground.com"
- }, {
- uuid: Math.uuid(null, 16),
+ };
+ contacts[id4] = {
+ uuid: id4,
firstName: "Donatello",
homePhone: "4563453425",
email1: "don@undergound.com"
- }];
+ };
+
+ return contacts;
}
function _get() {
@@ -51,13 +62,21 @@
db.saveObject(_KEY, contacts);
}
+//---------------------------------------------------
+//HACK: gotta fix the shiznit
+//TODO: if still here at 0.7.0 please remove
+var fix = _get();
+if (fix instanceof Array) {
+ _save(_defaultContacts());
+}
+//END OF HACK (may god have mercy on our souls)
+//---------------------------------------------------
+
_self = {
save: function (get, post) {
- var contacts = _get(),
- properties = post.contact,
- id = properties.uid;
+ var contacts = _get();
- contacts[id] = properties;
+ contacts[post.contact.uid] = post.contact;
_save(contacts);
return {code: 1};
},
@@ -81,7 +100,7 @@
match.max(post.maxReturn);
}
- return {code: 1, data: match.where(post.filterField)};
+ return {code: 1, data: match.where(post.fieldFilter)};
}
};
diff --git a/lib/ripple/platform/webworks/2.0.0/server/dialog.js b/lib/ripple/platform/webworks/2.0.0/server/dialog.js
index 975b614..24596fe 100644
--- a/lib/ripple/platform/webworks/2.0.0/server/dialog.js
+++ b/lib/ripple/platform/webworks/2.0.0/server/dialog.js
@@ -16,7 +16,6 @@
var constants = require('ripple/constants'),
event = require('ripple/event'),
devices = require('ripple/devices'),
- _console = require('ripple/console'),
ui = require('ripple/ui'),
utils = require('ripple/utils'),
isDialogVisible = false,
diff --git a/lib/ripple/platform/webworks/2.0.0/server/menu.js b/lib/ripple/platform/webworks/2.0.0/server/menu.js
index fc40083..4edc985 100644
--- a/lib/ripple/platform/webworks/2.0.0/server/menu.js
+++ b/lib/ripple/platform/webworks/2.0.0/server/menu.js
@@ -17,7 +17,6 @@
constants = require('ripple/constants'),
event = require('ripple/event'),
events = require('ripple/platform/webworks/2.0.0/client/events'),
- _console = require('ripple/console'),
ui = require('ripple/ui'),
devices = require('ripple/devices'),
utils = require('ripple/utils'),
diff --git a/lib/ripple/platform/webworks/2.0.0/server/sms.js b/lib/ripple/platform/webworks/2.0.0/server/sms.js
index bd3c19a..2c79c76 100644
--- a/lib/ripple/platform/webworks/2.0.0/server/sms.js
+++ b/lib/ripple/platform/webworks/2.0.0/server/sms.js
@@ -17,7 +17,6 @@
_isListeningForMessage,
notifications = require('ripple/notifications'),
constants = require('ripple/constants'),
- platform = require('ripple/platform'),
event = require('ripple/event'),
_console = require('ripple/console'),
_onReceive,
@@ -42,7 +41,7 @@
send: function (args) {
var msg = "To " + args.address + ": " + args.message;
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, msg);
- _console.log(platform.current().name + " :: " + msg);
+ _console.log(msg);
return {code: 1};
}
};
diff --git a/lib/ripple/platform/webworks/2.0.0/spec.js b/lib/ripple/platform/webworks/2.0.0/spec.js
index d2070d3..aeffdc7 100644
--- a/lib/ripple/platform/webworks/2.0.0/spec.js
+++ b/lib/ripple/platform/webworks/2.0.0/spec.js
@@ -52,8 +52,12 @@
children: {
pim: {
path: "webworks/2.0.0/client/pim",
- feature: "blackberry.pim.Task|blackberry.pim.Recurrence|blackberry.pim.Reminder|blackberry.pim.Appointment|blackberry.pim.Address|blackberry.pim.Attendee|blackberry.pim.Memo|blackberry.pim.Contact",
+ feature: "blackberry.pim.category|blackberry.pim.Task|blackberry.pim.Recurrence|blackberry.pim.Reminder|blackberry.pim.Appointment|blackberry.pim.Address|blackberry.pim.Attendee|blackberry.pim.Memo|blackberry.pim.Contact",
children: {
+ category: {
+ path: "webworks/2.0.0/client/category",
+ feature: "blackberry.pim.category"
+ },
Task: {
path: "webworks/2.0.0/client/Task",
feature: "blackberry.pim.Task"
diff --git a/lib/ripple/ui/plugins/deviceSettings.js b/lib/ripple/ui/plugins/deviceSettings.js
index 8e89aee..36b9004 100644
--- a/lib/ripple/ui/plugins/deviceSettings.js
+++ b/lib/ripple/ui/plugins/deviceSettings.js
@@ -88,9 +88,10 @@
switch (setting.control.type) {
case "checkbox":
jNode.bind("click", function () {
- deviceSettings.persist(fullKey, jQuery(this).attr("checked"));
+ var checked = this.checked ? true : false;
+ deviceSettings.persist(fullKey, checked);
if (typeof setting.callback === "function") {
- setting.callback(jQuery(this).attr("checked"));
+ setting.callback(checked);
}
});
diff --git a/lib/ripple/ui/plugins/phone.js b/lib/ripple/ui/plugins/phone.js
index 79da153..b38060e 100644
--- a/lib/ripple/ui/plugins/phone.js
+++ b/lib/ripple/ui/plugins/phone.js
@@ -17,7 +17,6 @@
Phone = require('ripple/platform/webworks/2.0.0/client/Phone'),
CallLog = require('ripple/platform/webworks/2.0.0/client/CallLog'),
event = require('ripple/event'),
- platform = require('ripple/platform'),
_console = require('ripple/console'),
eventSelect = document.getElementById("phone-event-types"),
eventErrorContainer = document.getElementById("phone-event-error-container"),
@@ -110,7 +109,7 @@
event.trigger("PhoneEvent", [type, callId, error]);
- _console.log(platform.current().name + " :: Fired PhoneEvent (type " + type + ") CallID: " +
+ _console.log("Fired PhoneEvent (type " + type + ") CallID: " +
callId + (error ? (" (error type " + error + ")") : ""));
}, false);
}
diff --git a/lib/ripple/ui/plugins/platformEvents.js b/lib/ripple/ui/plugins/platformEvents.js
index 0236f64..07e5521 100644
--- a/lib/ripple/ui/plugins/platformEvents.js
+++ b/lib/ripple/ui/plugins/platformEvents.js
@@ -83,7 +83,7 @@
if (events[select.value].args) {
args.push(eventArgs.value);
}
- _console.log(platform.current().name + " :: fired event => " + eventContext.context + "." + select.children[select.selectedIndex].innerText);
+ _console.log("fired event => " + eventContext.context + "." + select.children[select.selectedIndex].innerText);
try {
event.trigger(select.value, args);
}
diff --git a/lib/ripple/ui/plugins/telephony.js b/lib/ripple/ui/plugins/telephony.js
index 8440f80..a44b122 100644
--- a/lib/ripple/ui/plugins/telephony.js
+++ b/lib/ripple/ui/plugins/telephony.js
@@ -17,7 +17,6 @@
db = require('ripple/db'),
utils = require('ripple/utils'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
_optionTemplate = "<option value='[key]' [selected]>[value]</option>",
_textTemplate = "<td><input class='call-[key] ui-state-default ui-corner-all' type='text' value='[value]'></td>";
@@ -62,7 +61,7 @@
var calltype = jQuery(this).next().val(),
number = jQuery(this).parent().parent().prev().find(".call-number").val();
- _console.log(platform.current().name + " :: called Widget.Telephony.onCallEvent function [" + calltype + "," + number + "]");
+ _console.log("called Widget.Telephony.onCallEvent function [" + calltype + "," + number + "]");
if (Widget.Telephony.onCallEvent) {
Widget.Telephony.onCallEvent(calltype, number);
diff --git a/lib/ripple/widgetConfig.js b/lib/ripple/widgetConfig.js
index a10a487..9382e35 100644
--- a/lib/ripple/widgetConfig.js
+++ b/lib/ripple/widgetConfig.js
@@ -362,7 +362,7 @@
var validVersion = app.validateVersion(results);
if (!validVersion) {
- _console.warn(platform.current().name + " :: Your application does not appear to match" +
+ _console.warn("Your application does not appear to match" +
" the platform you have selected. The version number in your configuration might not " +
"match the selected platform version or your configuration file has errors in it.");
}
diff --git a/lib/ripple/xhr/base.js b/lib/ripple/xhr/base.js
index 2ee4e7d..5d6ca87 100644
--- a/lib/ripple/xhr/base.js
+++ b/lib/ripple/xhr/base.js
@@ -37,7 +37,7 @@
var newObj = {},
key;
- // need protoypes
+ // need prototypes
for (key in obj) {
if (typeof obj[key] === "function") {
newObj[key] = _handle(obj, key);
diff --git a/test/console.js b/test/console.js
index ea09448..0edaf59 100644
--- a/test/console.js
+++ b/test/console.js
@@ -16,23 +16,63 @@
describe("console", function () {
var _console = require('ripple/console');
- it("is an object", function () {
- expect(typeof _console).toBe("object");
+ beforeEach(function () {
+ _console.prefix = null;
});
- it("log is a function", function () {
- expect(typeof _console.log).toBe("function");
+ describe("when logging", function () {
+ it("calls the log method", function () {
+ spyOn(console, "log");
+ _console.log("beavers!!!");
+ expect(console.log).toHaveBeenCalledWith("beavers!!!");
+ });
});
- it("warn is a function", function () {
- expect(typeof _console.warn).toBe("function");
+ describe("when erroring", function () {
+ it("calls the error method", function () {
+ spyOn(console, "error");
+ _console.error("this is teh broken");
+ expect(console.error).toHaveBeenCalledWith("this is teh broken");
+ });
});
- it("error is a function", function () {
- expect(typeof _console.error).toBe("function");
+ describe("when warning", function () {
+ it("calls the warn method", function () {
+ spyOn(console, "warn");
+ _console.warn("Thundercats Hoooo");
+ expect(console.warn).toHaveBeenCalledWith("Thundercats Hoooo");
+ });
});
- it("clear is a function", function () {
- expect(typeof _console.clear).toBe("function");
+ describe("when setting the prefix", function () {
+ beforeEach(function () {
+ _console.prefix = "PLATFORM";
+ });
+
+ it("uses the prefix when logging", function () {
+ spyOn(console, "log");
+ _console.log("Thundercats Hoooo");
+ expect(console.log).toHaveBeenCalledWith("PLATFORM :: Thundercats Hoooo");
+ });
+
+ it("uses the prefix when erroring", function () {
+ spyOn(console, "error");
+ _console.error("Carebears Stare");
+ expect(console.error).toHaveBeenCalledWith("PLATFORM :: Carebears Stare");
+ });
+
+ it("uses the prefix when warning", function () {
+ spyOn(console, "warn");
+ _console.warn("Danger Will Robinson");
+ expect(console.warn).toHaveBeenCalledWith("PLATFORM :: Danger Will Robinson");
+ });
+
+ it("will not use a falsy prefix", function () {
+ _console.prefix = false;
+ spyOn(console, "log");
+ _console.log("EX-TERM-IN-ATE");
+ expect(console.log).toHaveBeenCalledWith("EX-TERM-IN-ATE");
+ });
});
+
});
diff --git a/test/emulatorBridge.js b/test/emulatorBridge.js
index c5a863b..53a5407 100644
--- a/test/emulatorBridge.js
+++ b/test/emulatorBridge.js
@@ -60,6 +60,12 @@
_emulatedDocument.appendChild(_emulatedHtml);
_emulatedViewport.appendChild(_emulatedDocument);
+ spyOn(platform, "current").andReturn({objects: {
+ foo: {a: 1},
+ bar: {b: 1},
+ woot: [1, 2, 3, 4, 5]
+ }});
+
emulatorBridge.link(_emulatedFrame);
});
@@ -116,12 +122,6 @@
});
it("it marshals over everything in the sandbox", function () {
- platform.sandbox.foo = {a: 1};
- platform.sandbox.bar = {b: 1};
- platform.sandbox.woot = [1, 2, 3, 4, 5];
-
- emulatorBridge.link(_emulatedFrame);
-
expect(window.foo).toBeDefined();
expect(window.bar).toBeDefined();
expect(window.woot).toBeDefined();
diff --git a/test/phonegap/navigator.js b/test/phonegap/navigator.js
index aeec428..c8a2a09 100644
--- a/test/phonegap/navigator.js
+++ b/test/phonegap/navigator.js
@@ -31,7 +31,6 @@
spyOn(emulatorBridge, "getWidgetDocument").andReturn(document);
spyOn(document, "dispatchEvent");
spyOn(_console, "log");
- spyOn(platform, "current").andReturn({name: "whatup"});
event.trigger("TinyHipposLoaded");
@@ -39,7 +38,6 @@
runs(function () {
expect(document.dispatchEvent.callCount).toEqual(1);
expect(_console.log.callCount).toEqual(1);
- expect(platform.current.callCount).toEqual(1);
});
});
diff --git a/test/platform.js b/test/platform.js
index cc1eaa5..e5a3c51 100644
--- a/test/platform.js
+++ b/test/platform.js
@@ -17,6 +17,7 @@
var platform = require('ripple/platform'),
db = require('ripple/db'),
+ app = require('ripple/app'),
builder = require('ripple/platform/builder'),
event = require('ripple/event'),
_console = require('ripple/console'),
@@ -34,7 +35,7 @@
platform.initialize();
});
- it("getPlatformNameValues should return correct value", function () {
+ it("getList should return correct value", function () {
var returnedPlatforms = platform.getList();
expect(typeof returnedPlatforms["wac"]["1.0"].id).toEqual("string");
@@ -42,45 +43,65 @@
expect(typeof returnedPlatforms["wac"]["1.0"].type).toEqual("string");
});
- it("changeEnvironment should persist successfully", function () {
- spyOn(platform, "initialize");
- spyOn(db, "saveObject").andCallFake(function (a, b, c, baton) {
- baton();
- });
- spyOn(db, "save").andCallFake(function (a, b, c, baton) {
- return baton && baton();
- });
- spyOn(event, "trigger");
- spyOn(resizer, "resize");
-
+ describe("when changing the environment", function () {
var platformSpec = {
name: "someplatform",
version: "1.0"
},
deviceId = "some_id";
- platform.changeEnvironment(platformSpec, deviceId);
+ beforeEach(function () {
+ spyOn(db, "saveObject").andCallFake(function (a, b, c, baton) {
+ baton();
+ });
- expect(db.saveObject.argsForCall[0][0]).toEqual("api-key");
- expect(db.save.argsForCall[0][0]).toEqual("device-key");
+ spyOn(db, "save").andCallFake(function (a, b, c, baton) {
+ return baton && baton();
+ });
- //Expected layout to be set to null in persistence
- expect(db.save.argsForCall[1][0]).toEqual(constants.ENCAPSULATOR.LAYOUT);
- expect(db.save.argsForCall[1][1]).toEqual(null);
+ spyOn(event, "trigger");
+ });
- expect(event.trigger.argsForCall[0][0]).toEqual("PlatformChangedEvent");
+ it("saves the platform", function () {
+ platform.changeEnvironment(platformSpec, deviceId, function () {
+ expect(db.saveObject.argsForCall[0][0]).toEqual("api-key");
+ expect(db.saveObject.argsForCall[0][1]).toEqual(platformSpec);
+ });
+ });
+
+ it("saves the device", function () {
+ platform.changeEnvironment(platformSpec, deviceId, function () {
+ expect(db.save.argsForCall[0][0]).toEqual("device-key");
+ expect(db.save.argsForCall[0][1]).toEqual("some_id");
+ });
+ });
+
+ it("removes the persisted value for the layout", function () {
+ platform.changeEnvironment(platformSpec, deviceId, function () {
+ expect(db.save.argsForCall[1][0]).toEqual("layout");
+ expect(db.save.argsForCall[1][1]).toBe(null);
+ });
+ });
+
+ it("triggers the platform changed event", function () {
+ platform.changeEnvironment(platformSpec, deviceId, function () {
+ expect(event.trigger).toHaveBeenCalledWith("PlatformChangedEvent", true);
+ });
+ });
});
- it("getID should return a string", function () {
- expect(typeof platform.current().id).toEqual("string");
+ it("returns the current platform", function () {
+ expect(platform.current()).toBeDefined();
});
- it("getVersion should return a string", function () {
- expect(typeof platform.current().version).toEqual("string");
- });
+ describe("when getting the persistence prefix", function () {
+ it("appends the provided id to the value from the platform", function () {
+ expect(platform.getPersistencePrefix("foo")).toBe(platform.current().persistencePrefix + "foo-");
+ });
- it("getDeviceSettings should return an object", function () {
- expect(typeof platform.current().device).toEqual("object");
+ it("gets the id from the app info if no id provided", function () {
+ spyOn(app, "getInfo").andReturn({ id: "w00t" });
+ expect(platform.getPersistencePrefix()).toBe(platform.current().persistencePrefix + "w00t-");
+ });
});
-
});
diff --git a/test/w3c/geolocation.js b/test/w3c/geolocation.js
index 252170e..4ee3ade 100644
--- a/test/w3c/geolocation.js
+++ b/test/w3c/geolocation.js
@@ -14,7 +14,6 @@
* limitations under the License.
*/
describe("w3c_geolocation", function () {
-
var sinon = require('sinon'),
s,
geo = require('ripple/geo'),
@@ -41,7 +40,6 @@
});
it("position info is updated on PositionInfoUpdatedEvent", function () {
-
var stamp = new Date();
event.trigger("PositionInfoUpdatedEvent", [{
@@ -49,8 +47,9 @@
longitude: 2,
altitude: 3,
altitudeAccuracy: 4,
- heading: 0,
- speed: 0,
+ accuracy: 5,
+ heading: 6,
+ speed: 7,
timeStamp: stamp
}]);
@@ -59,8 +58,9 @@
expect(2).toBe(pos.coords.longitude);
expect(3).toBe(pos.coords.altitude);
expect(4).toBe(pos.coords.altitudeAccuracy);
- expect(0).toBe(pos.coords.heading);
- expect(0).toBe(pos.coords.speed);
+ expect(5).toBe(pos.coords.accuracy);
+ expect(6).toBe(pos.coords.heading);
+ expect(7).toBe(pos.coords.speed);
expect(stamp.getTime()).toBe(pos.timestamp);
});
});
@@ -99,7 +99,6 @@
});
it("watchPosition calls the callback on the given interval", function () {
-
var watch = geolocation.watchPosition(
s.mock().thrice(),
s.mock().never(),
@@ -110,5 +109,4 @@
geolocation.clearWatch(watch);
});
});
-
});
diff --git a/test/web/geolocation.js b/test/web/geolocation.js
new file mode 100644
index 0000000..f38069b
--- /dev/null
+++ b/test/web/geolocation.js
@@ -0,0 +1,31 @@
+describe("w3c_geolocation", function () {
+ var w3c = "w3c/1.0/",
+ web = "ripple/platform/web/default/",
+ spec = require(web + 'spec'),
+ ui = require(web + 'spec/ui');
+
+ describe("spec", function () {
+ it("includes require modules", function () {
+ expect(spec.objects.Coordinates.path).toEqual(w3c + "Coordinates");
+ expect(spec.objects.Position.path).toEqual(w3c + "Position");
+ expect(spec.objects.PositionError.path).toEqual(w3c + "PositionError");
+ expect(spec.objects.navigator.children.geolocation.path).toEqual(w3c + "geolocation");
+ });
+
+ describe("ui", function () {
+ it("uses web/spec/ui module", function () {
+ expect(spec.ui.plugins).toEqual(ui.plugins);
+ });
+
+ it("includes geoView plugin", function () {
+ function includesGeoViewPlugin() {
+ return ui.plugins.some(function (plugin) {
+ return plugin === "geoView";
+ });
+ }
+
+ expect(includesGeoViewPlugin()).toBe(true);
+ });
+ });
+ });
+});
diff --git a/test/webworks/Message.js b/test/webworks/Message.js
index 13ecd7e..89e6308 100644
--- a/test/webworks/Message.js
+++ b/test/webworks/Message.js
@@ -165,7 +165,7 @@
describe("find", function () {
it("calls the transport with proper args", function () {
var messages = [];
- spyOn(transport, "call").andReturn({data: messages});
+ spyOn(transport, "call").andReturn(messages);
expect(Message.find(1, 2, 3)).toEqual(messages);
expect(transport.call).toHaveBeenCalledWith("blackberry/message/message/find", {
post: {
diff --git a/test/webworks/Task.js b/test/webworks/Task.js
index 1314a0d..7e5c314 100644
--- a/test/webworks/Task.js
+++ b/test/webworks/Task.js
@@ -110,7 +110,7 @@
describe("find", function () {
it("calls the transport with proper args", function () {
var tasks = [];
- spyOn(transport, "call").andReturn({data: tasks});
+ spyOn(transport, "call").andReturn(tasks);
expect(TaskClient.find(1, 2, 3, 4)).toEqual(tasks);
expect(transport.call).toHaveBeenCalledWith("blackberry/pim/Task/find", {
post: {
@@ -134,7 +134,7 @@
task.reminder = new Reminder();
task.reminder.date = new Date();
- spyOn(transport, "call").andReturn({data: [JSON.parse(JSON.stringify(task))]});
+ spyOn(transport, "call").andReturn([JSON.parse(JSON.stringify(task))]);
tasks = TaskClient.find();
diff --git a/test/webworks/app.js b/test/webworks/app.js
index 8245189..ffb280f 100644
--- a/test/webworks/app.js
+++ b/test/webworks/app.js
@@ -38,7 +38,7 @@
var data = "data";
beforeEach(function () {
- spyOn(transport, "call").andReturn({data: data});
+ spyOn(transport, "call").andReturn(data);
});
describe("exit", function () {
diff --git a/test/webworks/appointment.js b/test/webworks/appointment.js
index 5e90eb3..d8c7682 100644
--- a/test/webworks/appointment.js
+++ b/test/webworks/appointment.js
@@ -34,7 +34,7 @@
describe("client", function () {
describe("save", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: 2});
+ spyOn(transport, "call").andReturn(2);
spyOn(Math, "uuid").andReturn("33");
var app = new Appointment();
@@ -49,7 +49,7 @@
describe("remove", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: 2});
+ spyOn(transport, "call").andReturn(2);
var app = new Appointment();
app.uid = 345;
@@ -64,7 +64,7 @@
describe("when finding appointments", function () {
it("calls the transport with proper args", function () {
var apps = [];
- spyOn(transport, "call").andReturn({data: apps});
+ spyOn(transport, "call").andReturn(apps);
expect(Appointment.find(1, 2, 3, 4, 5)).toEqual(apps);
expect(transport.call).toHaveBeenCalledWith("blackberry/pim/appointment/find", {
post: {
@@ -90,7 +90,7 @@
appointment.reminder = new Reminder();
appointment.reminder.date = new Date();
- spyOn(transport, "call").andReturn({data: [JSON.parse(JSON.stringify(appointment))]});
+ spyOn(transport, "call").andReturn([JSON.parse(JSON.stringify(appointment))]);
appointments = Appointment.find();
diff --git a/test/webworks/audioPlayer.js b/test/webworks/audioPlayer.js
index e5d40b6..695aa92 100644
--- a/test/webworks/audioPlayer.js
+++ b/test/webworks/audioPlayer.js
@@ -61,7 +61,7 @@
beforeEach(function () {
spyOn(transport, "call").andCallFake(function (uri) {
- return {data: uri.match(/\/create$/) ? id : data};
+ return uri.match(/\/create$/) ? id : data;
});
});
diff --git a/test/webworks/blackberry.js b/test/webworks/blackberry.js
index 7279201..efb280c 100644
--- a/test/webworks/blackberry.js
+++ b/test/webworks/blackberry.js
@@ -29,7 +29,7 @@
describe("using client/identity", function () {
describe("network", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "the network"});
+ spyOn(transport, "call").andReturn("the network");
expect(blackberry.network).toEqual("the network");
expect(transport.call).toHaveBeenCalledWith("blackberry/system/network");
});
diff --git a/test/webworks/category.js b/test/webworks/category.js
index 6e7ba81..5de9b14 100644
--- a/test/webworks/category.js
+++ b/test/webworks/category.js
@@ -15,8 +15,8 @@
*/
describe("webworks pim.category", function () {
- var pim = require('ripple/platform/webworks/2.0.0/client/pim'),
- category = require('ripple/platform/webworks/2.0.0/server/category'),
+ var categoryClient = require('ripple/platform/webworks/2.0.0/client/category'),
+ categoryServer = require('ripple/platform/webworks/2.0.0/server/category'),
spec = require('ripple/platform/webworks/2.0.0/spec'),
transport = require('ripple/platform/webworks/2.0.0/client/transport'),
webworks = require('ripple/platform/webworks/2.0.0/server'),
@@ -25,14 +25,14 @@
describe("server index", function () {
it("exposes the category module", function () {
- expect(webworks.blackberry.pim.category).toEqual(category);
+ expect(webworks.blackberry.pim.category).toEqual(categoryServer);
});
});
describe("platform spec", function () {
it("includes the module according to proper object structure", function () {
- expect(spec.objects.blackberry.children.pim.path)
- .toEqual("webworks/2.0.0/client/pim");
+ expect(spec.objects.blackberry.children.pim.children.category.path)
+ .toEqual("webworks/2.0.0/client/category");
});
});
@@ -40,7 +40,7 @@
describe("addCategory", function () {
it("calls the transport with proper args", function () {
spyOn(transport, "call");
- pim.addCategory("x");
+ categoryClient.addCategory("x");
expect(transport.call)
.toHaveBeenCalledWith("blackberry/pim/category/addCategory", {get: {categoryName: "x"}});
});
@@ -49,7 +49,7 @@
describe("deleteCategory", function () {
it("calls the transport with proper args", function () {
spyOn(transport, "call");
- pim.deleteCategory("y");
+ categoryClient.deleteCategory("y");
expect(transport.call)
.toHaveBeenCalledWith("blackberry/pim/category/deleteCategory", {get: {categoryName: "y"}});
});
@@ -57,8 +57,8 @@
describe("getCategories", function () {
it("calls the transport with proper args", function () {
- spyOn(transport, "call").andReturn({data: "z"});
- expect(pim.getCategories()).toEqual("z");
+ spyOn(transport, "call").andReturn("z");
+ expect(categoryClient.getCategories()).toEqual("z");
expect(transport.call)
.toHaveBeenCalledWith("blackberry/pim/category/getCategories");
});
@@ -71,7 +71,7 @@
it("returns the current list of categories", function () {
var categories = [];
spyOn(db, "retrieveObject").andReturn(categories);
- expect(category.getCategories().data).toEqual(categories);
+ expect(categoryServer.getCategories().data).toEqual(categories);
});
});
@@ -85,14 +85,14 @@
});
it("adds categories", function () {
- category.addCategory({categoryName: "people"});
- category.addCategory({categoryName: "fun people"});
+ categoryServer.addCategory({categoryName: "people"});
+ categoryServer.addCategory({categoryName: "fun people"});
expect(categories.length).toEqual(2);
expect(categories).toEqual(["people", "fun people"]);
});
it("persists the category", function () {
- category.addCategory({categoryName: "more fun people"});
+ categoryServer.addCategory({categoryName: "more fun people"});
expect(db.saveObject).toHaveBeenCalledWith("blackberry-pim-category", ["more fun people"]);
});
});
@@ -107,15 +107,15 @@
});
it("deletes a category", function () {
- category.addCategory({categoryName: "the beautiful people"});
- category.deleteCategory({categoryName: "the beautiful people"});
+ categoryServer.addCategory({categoryName: "the beautiful people"});
+ categoryServer.deleteCategory({categoryName: "the beautiful people"});
expect(categories.length).toEqual(0);
expect(categories).toEqual([]);
});
it("persists the new category list", function () {
- category.addCategory({categoryName: "name"});
- category.deleteCategory({categoryName: "name"});
+ categoryServer.addCategory({categoryName: "name"});
+ categoryServer.deleteCategory({categoryName: "name"});
expect(db.saveObject).toHaveBeenCalledWith("blackberry-pim-category", []);
});
});
diff --git a/test/webworks/contact.js b/test/webworks/contact.js
index b339eb2..29db91f 100644
--- a/test/webworks/contact.js
+++ b/test/webworks/contact.js
@@ -95,7 +95,7 @@
describe("find", function () {
it("calls the transport with proper args", function () {
var contacts = [];
- spyOn(transport, "call").andReturn({data: contacts});
+ spyOn(transport, "call").andReturn(contacts);
expect(Contact.find(1, 2, 3, 4, 5)).toEqual(contacts);
expect(transport.call).toHaveBeenCalledWith("blackberry/pim/contact/find", {
post: {
@@ -117,7 +117,7 @@
item.birthday = new Date();
item.anniversary = new Date();
- spyOn(transport, "call").andReturn({data: [JSON.parse(JSON.stringify(item))]});
+ spyOn(transport, "call").andReturn([JSON.parse(JSON.stringify(item))]);
contacts = Contact.find();
@@ -147,7 +147,7 @@
it("calls select module with filter expression", function () {
var filter = new FilterExpression();
- contact.find({}, {filterField: filter});
+ contact.find({}, {fieldFilter: filter});
expect(chain.where).toHaveBeenCalledWith(filter);
});
diff --git a/test/webworks/dialog.js b/test/webworks/dialog.js
index 7521fc8..7fc9d0d 100644
--- a/test/webworks/dialog.js
+++ b/test/webworks/dialog.js
@@ -42,7 +42,7 @@
describe("client", function () {
describe("customAskAsync", function () {
it("calls the transport appropriately", function () {
- spyOn(transport, "call").andReturn({data: "data"});
+ spyOn(transport, "call").andReturn("data");
expect(dialogClient.customAskAsync("msg", "choices")).toEqual("data");
expect(transport.call.argsForCall[0][0]).toEqual("blackberry/ui/dialog/ask");
@@ -59,7 +59,7 @@
var callback = jasmine.createSpy();
spyOn(transport, "call").andCallFake(function (a, b, callback) {
- var response = {data: "data"};
+ var response = "data";
if (callback) {
callback(response);
}
@@ -73,7 +73,7 @@
describe("customAskAsync", function () {
it("calls the transport appropriately", function () {
- spyOn(transport, "call").andReturn({data: "data"});
+ spyOn(transport, "call").andReturn("data");
expect(dialogClient.standardAskAsync("msg", dialogClient.D_YES_NO)).toEqual("data");
expect(transport.call.argsForCall[0][0]).toEqual("blackberry/ui/dialog/ask");
@@ -90,7 +90,7 @@
var callback = jasmine.createSpy();
spyOn(transport, "call").andCallFake(function (a, b, callback) {
- var response = {data: "data"};
+ var response = "data";
if (callback) {
callback(response);
}
diff --git a/test/webworks/identity/Transport.js b/test/webworks/identity/Transport.js
index a4b170f..076e65e 100644
--- a/test/webworks/identity/Transport.js
+++ b/test/webworks/identity/Transport.js
@@ -34,17 +34,15 @@
describe("name", function () {
it("is readonly", function () {
- expect(function () {
- new Transport().name = "";
- }).toThrow();
+ expect(new Transport().__lookupGetter__("name")).toBeDefined();
+ expect(new Transport().__lookupSetter__("name")).not.toBeDefined();
});
});
describe("type", function () {
it("is readonly", function () {
- expect(function () {
- new Transport().type = "";
- }).toThrow();
+ expect(new Transport().__lookupGetter__("type")).toBeDefined();
+ expect(new Transport().__lookupSetter__("type")).not.toBeDefined();
});
});
});
diff --git a/test/webworks/identity/identity.js b/test/webworks/identity/identity.js
index 6ffc9d2..862da44 100644
--- a/test/webworks/identity/identity.js
+++ b/test/webworks/identity/identity.js
@@ -40,7 +40,7 @@
describe("using client/identity", function () {
describe("IMEI", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "into eternity"});
+ spyOn(transport, "call").andReturn("into eternity");
expect(identityClient.IMEI).toEqual("into eternity");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/IMEI");
});
@@ -48,7 +48,7 @@
describe("IMSI", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "the oblivion"});
+ spyOn(transport, "call").andReturn("the oblivion");
expect(identityClient.IMSI).toEqual("the oblivion");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/IMSI");
});
@@ -56,7 +56,7 @@
describe("PIN", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "takes all"});
+ spyOn(transport, "call").andReturn("takes all");
expect(identityClient.PIN).toEqual("takes all");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/PIN");
});
@@ -64,7 +64,7 @@
describe("getServiceList", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "the conqueror worm"});
+ spyOn(transport, "call").andReturn("the conqueror worm");
expect(identityClient.getServiceList()).toEqual("the conqueror worm");
expect(transport.call)
.toHaveBeenCalledWith("blackberry/identity/getServiceList");
@@ -73,7 +73,7 @@
describe("getDefaultService", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "the tragedy"});
+ spyOn(transport, "call").andReturn("the tragedy");
expect(identityClient.getDefaultService()).toEqual("the tragedy");
expect(transport.call)
.toHaveBeenCalledWith("blackberry/identity/getDefaultService");
@@ -82,7 +82,7 @@
describe("getTransportList", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "is man"});
+ spyOn(transport, "call").andReturn("is man");
expect(identityClient.getTransportList()).toEqual("is man");
expect(transport.call)
.toHaveBeenCalledWith("blackberry/identity/getTransportList");
diff --git a/test/webworks/identity/phone.js b/test/webworks/identity/phone.js
index 6fc6ca1..9164351 100644
--- a/test/webworks/identity/phone.js
+++ b/test/webworks/identity/phone.js
@@ -37,7 +37,7 @@
describe("in client/phone", function () {
describe("getLineIds", function () {
it("calls the transport", function () {
- spyOn(transport, "call").andReturn({data: "need more coffee"});
+ spyOn(transport, "call").andReturn("need more coffee");
expect(phoneClient.getLineIds()).toEqual("need more coffee");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/phone/getLineIds");
});
@@ -45,7 +45,7 @@
describe("getLineLabel", function () {
it("calls the transport with proper args", function () {
- spyOn(transport, "call").andReturn({data: "your face"});
+ spyOn(transport, "call").andReturn("your face");
expect(phoneClient.getLineLabel(1)).toEqual("your face");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/phone/getLineLabel", {get: {id: 1}});
});
@@ -53,7 +53,7 @@
describe("getLineNumber", function () {
it("calls the transport with proper args", function () {
- spyOn(transport, "call").andReturn({data: "where in the world"});
+ spyOn(transport, "call").andReturn("where in the world");
expect(phoneClient.getLineNumber(3)).toEqual("where in the world");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/phone/getLineNumber", {get: {id: 3}});
});
@@ -61,7 +61,7 @@
describe("getLineType", function () {
it("calls the transport with proper args", function () {
- spyOn(transport, "call").andReturn({data: "is carmen sandiego"});
+ spyOn(transport, "call").andReturn("is carmen sandiego");
expect(phoneClient.getLineType(2)).toEqual("is carmen sandiego");
expect(transport.call).toHaveBeenCalledWith("blackberry/identity/phone/getLineType", {get: {id: 2}});
});
diff --git a/test/webworks/memo.js b/test/webworks/memo.js
index c845676..d67884e 100644
--- a/test/webworks/memo.js
+++ b/test/webworks/memo.js
@@ -33,7 +33,7 @@
describe("find", function () {
it("calls the transport with proper args", function () {
var memos = [];
- spyOn(transport, "call").andReturn({data: memos});
+ spyOn(transport, "call").andReturn(memos);
expect(Memo.find(1, 2, 3, 4, 5)).toEqual(memos);
expect(transport.call).toHaveBeenCalledWith("blackberry/pim/memo/find", {
post: {
diff --git a/test/webworks/phone.js b/test/webworks/phone.js
index 1f7583e..69fb6c3 100644
--- a/test/webworks/phone.js
+++ b/test/webworks/phone.js
@@ -88,7 +88,7 @@
log.date = new Date();
- spyOn(transport, "call").andReturn({data: JSON.parse(JSON.stringify(log))});
+ spyOn(transport, "call").andReturn(JSON.parse(JSON.stringify(log)));
expect(PhoneLogs.callAt(opts.get.index, opts.get.folderID)).toEqual(log);
expect(transport.call).toHaveBeenCalledWith("blackberry/phone/logs/callAt", opts);
@@ -102,7 +102,7 @@
folderID: "ID"
};
- spyOn(transport, "call").andReturn({data: "boolean"});
+ spyOn(transport, "call").andReturn("boolean");
expect(PhoneLogs.deleteCallAt(get.index, get.folderID)).toEqual("boolean");
expect(transport.call).toHaveBeenCalledWith("blackberry/phone/logs/deleteCallAt", {get: get});
@@ -112,7 +112,7 @@
describe("find", function () {
it("calls the transport with proper args", function () {
var logs = [];
- spyOn(transport, "call").andReturn({data: logs});
+ spyOn(transport, "call").andReturn(logs);
expect(PhoneLogs.find(1, 2, 3, 4, 5)).toEqual(logs);
expect(transport.call).toHaveBeenCalledWith("blackberry/phone/logs/find", {
post: {
@@ -132,7 +132,7 @@
log.date = new Date();
log.name = "test";
- spyOn(transport, "call").andReturn({data: [JSON.parse(JSON.stringify(log))]});
+ spyOn(transport, "call").andReturn([JSON.parse(JSON.stringify(log))]);
logs = PhoneLogs.find();
@@ -150,7 +150,7 @@
}
};
- spyOn(transport, "call").andReturn({data: 3});
+ spyOn(transport, "call").andReturn(3);
expect(PhoneLogs.numberOfCalls(opts.get.folderID)).toEqual(3);
expect(transport.call).toHaveBeenCalledWith("blackberry/phone/logs/numberOfCalls", opts);
@@ -161,7 +161,6 @@
describe("Phone", function () {
describe("addPhoneListener", function () {
it("polls the transport", function () {
- var response = {data: "array of active calls"};
spyOn(transport, "poll");
expect(Phone.addPhoneListener(function () {}, "random type")); // sticks around..
expect(transport.poll.argsForCall[0][0]).toEqual("blackberry/phone/onPhoneEvent");
@@ -173,16 +172,16 @@
describe("activeCalls", function () {
it("calls the transport", function () {
- var response = {data: "array of active calls"};
+ var response = "array of active calls";
spyOn(transport, "call").andReturn(response);
- expect(Phone.activeCalls()).toEqual(response.data);
+ expect(Phone.activeCalls()).toEqual(response);
expect(transport.call).toHaveBeenCalledWith("blackberry/phone/activeCalls");
});
});
describe("inActiveCall", function () {
it("calls the transport", function () {
- var response = {data: "boolean"};
+ var response = "boolean";
spyOn(transport, "call").andReturn(response);
expect(Phone.inActiveCall()).toEqual("boolean");
expect(transport.call).toHaveBeenCalledWith("blackberry/phone/inActiveCall");
diff --git a/test/webworks/system.js b/test/webworks/system.js
index 13c5c0f..3cab5ea 100644
--- a/test/webworks/system.js
+++ b/test/webworks/system.js
@@ -37,7 +37,7 @@
describe("client", function () {
describe("hasCapability", function () {
it("calls the transport with id and properties", function () {
- spyOn(transport, "call").andReturn({data: 2});
+ spyOn(transport, "call").andReturn(2);
expect(client.hasCapability("epic")).toEqual(2);
expect(transport.call).toHaveBeenCalledWith("blackberry/system/hasCapability", {
@@ -48,7 +48,7 @@
describe("hasDataCoverage", function () {
it("calls the transport with id and properties", function () {
- spyOn(transport, "call").andReturn({data: 4});
+ spyOn(transport, "call").andReturn(4);
expect(client.hasDataCoverage()).toEqual(4);
expect(transport.call).toHaveBeenCalledWith("blackberry/system/hasDataCoverage");
});
@@ -56,7 +56,7 @@
describe("hasPermission", function () {
it("calls the transport with id and properties", function () {
- spyOn(transport, "call").andReturn({data: 2});
+ spyOn(transport, "call").andReturn(2);
expect(client.hasPermission("something")).toEqual(2);
expect(transport.call).toHaveBeenCalledWith("blackberry/system/hasPermission", {
@@ -67,7 +67,7 @@
describe("isMassStorageActive", function () {
it("calls the transport with id and properties", function () {
- spyOn(transport, "call").andReturn({data: true});
+ spyOn(transport, "call").andReturn(true);
expect(client.isMassStorageActive()).toEqual(true);
expect(transport.call).toHaveBeenCalledWith("blackberry/system/isMassStorageActive");
});
diff --git a/test/webworks/transport.js b/test/webworks/transport.js
index 96d3392..17eaf65 100644
--- a/test/webworks/transport.js
+++ b/test/webworks/transport.js
@@ -29,11 +29,11 @@
describe("poll", function () {
it("calls a uri with callback", function () {
var callback = jasmine.createSpy().andReturn(false),
- response = "txt",
+ response = {code: 0, data: "txt"},
uri = "uri";
spyOn(transport, "call").andCallFake(function (uri, opts, func) {
- func(response);
+ func(response.data, response);
});
transport.poll(uri, {get: {}}, callback);
@@ -41,7 +41,7 @@
expect(transport.call.argsForCall[0][0]).toEqual(uri);
expect(transport.call.argsForCall[0][1]).toEqual({async: true, get: {}});
expect(typeof transport.call.argsForCall[0][2]).toEqual("function");
- expect(callback).toHaveBeenCalledWith(response);
+ expect(callback).toHaveBeenCalledWith("txt", response);
});
});
@@ -50,7 +50,7 @@
beforeEach(function () {
spyOn(global, "XMLHttpRequest").andReturn(xhr = {
- responseText: "4",
+ responseText: JSON.stringify({data: 4}),
open: jasmine.createSpy(),
send: jasmine.createSpy(),
setRequestHeader: jasmine.createSpy()
@@ -74,7 +74,7 @@
};
transport.call("some/uri", {post: params});
- expect(xhr.send).toHaveBeenCalledWith('key="value"&key2="value2"');
+ expect(xhr.send).toHaveBeenCalledWith('key=%22value%22&key2=%22value2%22');
});
it("can make a synchronous call", function () {
@@ -88,16 +88,78 @@
});
it("passes a callback for an asynchronous call", function () {
- var callback = jasmine.createSpy();
+ var success = jasmine.createSpy();
xhr.readyState = 4;
xhr.status = 200;
- transport.call("some/uri", {async: true}, callback);
+ transport.call("some/uri", {async: true}, success);
xhr.onreadystatechange();
expect(xhr.open).toHaveBeenCalledWith("POST", "webworks://some/uri", true);
- expect(callback).toHaveBeenCalledWith(JSON.parse(xhr.responseText));
+ expect(success).toHaveBeenCalledWith(4, {data: 4});
+ });
+
+ });
+
+ describe("when handling errors", function () {
+ describe("when calling errr 'call'", function () {
+ var xhr;
+
+ beforeEach(function () {
+ spyOn(global, "XMLHttpRequest").andReturn(xhr = {
+ responseText: JSON.stringify({data: 4}),
+ open: jasmine.createSpy(),
+ send: jasmine.createSpy(),
+ setRequestHeader: jasmine.createSpy()
+ });
+ });
+
+ it("calls the error callback for async", function () {
+ var success = jasmine.createSpy(),
+ error = jasmine.createSpy();
+
+ xhr.readyState = 4;
+ xhr.status = 200;
+
+ xhr.responseText = JSON.stringify({code: -1, data: "woot", msg: "bad moon"});
+
+ transport.call("some/uri", {async: true}, success, error);
+ xhr.onreadystatechange();
+
+ expect(success).not.toHaveBeenCalled();
+ expect(error).toHaveBeenCalledWith("bad moon", JSON.parse(xhr.responseText));
+ });
+
+ it("calls the error callback for sync", function () {
+ var success = jasmine.createSpy(),
+ error = jasmine.createSpy();
+
+ xhr.readyState = 4;
+ xhr.status = 200;
+
+ xhr.responseText = JSON.stringify({code: -1, data: "woot", msg: "bad moon"});
+
+ transport.call("some/uri", {async: false}, success, error);
+
+ expect(success).not.toHaveBeenCalled();
+ expect(error).toHaveBeenCalledWith("bad moon", JSON.parse(xhr.responseText));
+ });
+
+ it("throws an exception for sync calls with no error callback", function () {
+
+ var success = jasmine.createSpy(),
+ error = jasmine.createSpy();
+
+ xhr.readyState = 4;
+ xhr.status = 200;
+
+ xhr.responseText = JSON.stringify({code: -5, data: "ddd", msg: "mer"});
+
+ expect(function () {
+ transport.call("some/uri");
+ }).toThrow("mer");
+ });
});
});
});