You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/12/10 22:04:28 UTC
[2/3] spec commit: correct way to detect windows phone (both 7/8)
correct way to detect windows phone (both 7/8)
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/05ad8280
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/05ad8280
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/05ad8280
Branch: refs/heads/master
Commit: 05ad8280e5089cea4c90f09da04232e735427c6c
Parents: 74523ac
Author: sgrebnov <se...@gmail.com>
Authored: Wed Oct 30 17:58:49 2013 +0400
Committer: sgrebnov <se...@gmail.com>
Committed: Wed Dec 4 16:14:06 2013 +0400
----------------------------------------------------------------------
autotest/tests/contacts.tests.js | 25 ++++++++++++-------------
autotest/tests/datauri.tests.js | 9 ++++-----
2 files changed, 16 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/05ad8280/autotest/tests/contacts.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/contacts.tests.js b/autotest/tests/contacts.tests.js
index 14459ed..de2955e 100644
--- a/autotest/tests/contacts.tests.js
+++ b/autotest/tests/contacts.tests.js
@@ -21,11 +21,10 @@
// global to store a contact so it doesn't have to be created or retrieved multiple times
// all of the setup/teardown test methods can reference the following variables to make sure to do the right cleanup
-var gContactObj = null;
-var gContactId = null;
-var isWP8 = function() {
- return window.device && window.device.platform && window.device.platform.toLowerCase() == 'win32nt';
-};
+var gContactObj = null,
+ gContactId = null,
+ isWindowsPhone = cordova.platformId == 'windowsphone';
+
var removeContact = function(){
if (gContactObj) {
gContactObj.remove(function(){},function(){
@@ -126,8 +125,8 @@ describe("Contacts (navigator.contacts)", function () {
it("contacts.spec.6 should be able to find a contact by name", function() {
- // this api requires manual user confirmation on WP8 so skip it
- if (isWP8()) return;
+ // this api requires manual user confirmation on WP7/8 so skip it
+ if (isWindowsPhone) return;
var foundName = jasmine.createSpy().andCallFake(function(result) {
var bFound = false;
@@ -329,8 +328,8 @@ describe("Contacts (navigator.contacts)", function () {
describe('save method', function () {
it("contacts.spec.20 should be able to save a contact", function() {
- // this api requires manual user confirmation on WP8 so skip it
- if (isWP8()) return;
+ // this api requires manual user confirmation on WP7/8 so skip it
+ if (isWindowsPhone) return;
var bDay = new Date(1976, 6,4);
gContactObj = navigator.contacts.create({"gender": "male", "note": "my note", "name": {"familyName": "Delete", "givenName": "Test"}, "emails": [{"value": "here@there.com"}, {"value": "there@here.com"}], "birthday": bDay});
@@ -363,8 +362,8 @@ describe("Contacts (navigator.contacts)", function () {
// HACK: there is a reliance between the previous and next test. This is bad form.
it("contacts.spec.21 update a contact", function() {
- // this api requires manual user confirmation on WP8 so skip it
- if (isWP8()) return;
+ // this api requires manual user confirmation on WP7/8 so skip it
+ if (isWindowsPhone) return;
expect(gContactObj).toBeDefined();
@@ -444,8 +443,8 @@ describe("Contacts (navigator.contacts)", function () {
describe("Round trip Contact tests (creating + save + delete + find).", function () {
it("contacts.spec.24 Creating, saving, finding a contact should work, removing it should work, after which we should not be able to find it, and we should not be able to delete it again.", function() {
- // this api requires manual user confirmation on WP8 so skip it
- if (isWP8()) return;
+ // this api requires manual user confirmation on WP7/8 so skip it
+ if (isWindowsPhone) return;
var done = false;
runs(function () {
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/05ad8280/autotest/tests/datauri.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/datauri.tests.js b/autotest/tests/datauri.tests.js
index a996667..08ebbbc 100644
--- a/autotest/tests/datauri.tests.js
+++ b/autotest/tests/datauri.tests.js
@@ -16,15 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-var isWP8 = function() {
- return window.device && window.device.platform && window.device.platform.toLowerCase() == 'win32nt';
-};
+var isWindowsPhone = cordova.platformId == 'windowsphone';
+
describe('data uris', function () {
it("datauri.spec.1 should work with iframes", function() {
- // IE on WP8 considers 'data:' in frame.src string as protocol type
+ // IE on WP7/8 considers 'data:' in frame.src string as protocol type
// so asks user to look for appropriating application in the market;
// temporary skipped since requires user interaction
- if (isWP8()) return;
+ if (isWindowsPhone) return;
var gotFoo = false,
frame = document.createElement('iframe');
function onMessage(msg) {