Repository: cordova-osx Updated Branches: refs/heads/master 22cba9ef2 -> 8ac659c72
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/cordova-plugin-whitelist/doc/zh/README.md ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/cordova-plugin-whitelist/doc/zh/README.md b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/doc/zh/README.md new file mode 100644 index 0000000..c2c7e11 --- /dev/null +++ b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/doc/zh/README.md @@ -0,0 +1,148 @@ +<!-- +# license: Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +--> + +# cordova-plugin-whitelist + +éå夿ç¨å¼å¯¦ç¾ä¸åç¨æ¼å°èªå¨ç§ç¾å¤ç¦ 4.0 æç¨ç¨å¼ web è¦åçç½åå®çç¥ + +## æ¯æ´çç§ç¾å¤ç¦å¹³èº + + * Android 4.0.0 æä»¥ä¸ + * iOS 4.0.0 æä»¥ä¸ + +## å°èªç½åå® + +æ§å¶ web è¦åæ¬èº«å¯ä»¥å°èªå°ç Urlãé©ç¨äºé ç´å°èªåªã + +æªç: å¨ Android ä¸å®ä¹é©ç¨äº iframe çé-çµè¨ç«ã + +é è¨æ æ³ä¸ï¼åªæå°`file://` Url å°èªå 許ãè¥è¦å è¨±å ¶ä»å ¶ä» Urlï¼å¿ é å°`<allow-navigation>`æ¨ç±¤æ·»å å°æ¨ç`config.xml`: + + <!-- Allow links to example.com --> + <allow-navigation href="http://example.com/*" /> + + <!-- Wildcards are allowed for the protocol, as a prefix + to the host, or as a suffix to the path --> + <allow-navigation href="*://*.example.com/*" /> + + <!-- A wildcard can be used to whitelist the entire network, + over HTTP and HTTPS. + *NOT RECOMMENDED* --> + <allow-navigation href="*" /> + + <!-- The above is equivalent to these three declarations --> + <allow-navigation href="http://*/*" /> + <allow-navigation href="https://*/*" /> + <allow-navigation href="data:*" /> + + +## ç§ç¾å¤ç¦-夿ç¨å¼-ç½åå® + +æ§å¶æç¨ç¨å¼å 許è®ç³»çµ±æéç Urlã é è¨æ æ³ä¸ï¼æ²æå¤é¨ Url å 許ã + +å¨ android 系統ï¼éç¸ç¶æ¼ç¼éé¡å BROWSEABLE çæåã + +æ¤ç½åå®ä¸¦ä¸é©ç¨äºåªè¶ é£çµåå°`window.open ()`調ç¨ç夿ç¨å¼. + +å¨`config.xml`䏿·»å `<allow-intent>`æ¨ç±¤ï¼å鿍£: + + <!-- Allow links to web pages to open in a browser --> + <allow-intent href="http://*/*" /> + <allow-intent href="https://*/*" /> + + <!-- Allow links to example.com to open in a browser --> + <allow-intent href="http://example.com/*" /> + + <!-- Wildcards are allowed for the protocol, as a prefix + to the host, or as a suffix to the path --> + <allow-intent href="*://*.example.com/*" /> + + <!-- Allow SMS links to open messaging app --> + <allow-intent href="sms:*" /> + + <!-- Allow tel: links to open the dialer --> + <allow-intent href="tel:*" /> + + <!-- Allow geo: links to open maps --> + <allow-intent href="geo:*" /> + + <!-- Allow all unrecognized URLs to open installed apps + *NOT RECOMMENDED* --> + <allow-intent href="*" /> + + +## ç¶²è·¯è«æ±ç½åå® + +ç¶²è·¯è«æ±çæ§å¶é (ååï¼XHRs ç) å 許 (ééç§ç¾å¤ç¦æ¬æ©æé¤)ã + +注æ: æå建è°ä½ 使ç¨å §å®¹çå®å ¨æ§åå (è¦ä¸æ)ï¼éæ¯æ´å®å ¨ã æ¤ç½åå®å¤§å¤æ¯çº webviews 䏿¯æ´ CSP çæ·å²ã + +å¨`config.xml`䏿·»å `<access>`æ¨è¨ï¼å鿍£: + + <!-- Allow images, xhrs, etc. to google.com --> + <access origin="http://google.com" /> + <access origin="https://google.com" /> + + <!-- Access to the subdomain maps.google.com --> + <access origin="http://maps.google.com" /> + + <!-- Access to all the subdomains on google.com --> + <access origin="http://*.google.com" /> + + <!-- Enable requests to content: URLs --> + <access origin="content:///*" /> + + <!-- Don't block any requests --> + <access origin="*" /> + + +æ²æä»»ä½`<access>`æ¨ç±¤ï¼åªå°`file://` Url å è¨±è«æ±ã 使¯ï¼é è¨çç§ç¾å¤ç¦æç¨ç¨å¼å æ¬`<access origin="*">` ï¼é è¨æ æ³ã + +æªç: Android éå è¨±å° HTTPs://ssl.gstatic.com/accessibility/javascript/android/ è«æ±é è¨æ æ³ä¸ï¼å çºéæ¯å°è¬æ£å¸¸æéã + +### å §å®¹å®å ¨æ¿ç + +ç¶²è·¯è«æ±çæ§å¶é (ååï¼XHRs ç) å 許 (éé web è¦åç´æ¥)ã + +å° Android å iOSï¼ç¶²è·¯è«æ±ç½åå® (è¦ä¸æ) æ¯ä¸è½å¤ éæ¿¾ææé¡åçè«æ± (ä¾å¦`<video>` & Websocket æªè¢«é»æ¢)ã é£éº¼ï¼é¤äºç½åå®ä¸ï¼ä½ æä½¿ç¨[å §å®¹å®å ¨æ§åå](http://content-security-policy.com/) `< å >`æ¨è¨æ¨çææé é¢ã + +å¨ android 系統ï¼å° CSP 系統 web è¦åçæ¯æ´éå§å¥å·§ (使¯æ¯ä¸ä½¿ç¨ web è¦åäººè¡æ©«éä¸çææçæ¬å¯ç¨)ã + +ä¸é¢æ¯ä¸äºç¤ºä¾ CSP è²æçº`.html`é é¢: + + <!-- Good default declaration: + * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication + * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly + * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this: + * Enable inline JS: add 'unsafe-inline' to default-src + * Enable eval(): add 'unsafe-eval' to default-src + --> + <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *"> + + <!-- Allow requests to foo.com --> + <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com"> + + <!-- Enable all requests, inline styles, and eval() --> + <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> + + <!-- Allow XHRs via https only --> + <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:"> + + <!-- Allow iframe to https://cordova.apache.org/ --> + <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org"> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/cordova-plugin-whitelist/package.json ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/cordova-plugin-whitelist/package.json b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/package.json new file mode 100644 index 0000000..ca599b6 --- /dev/null +++ b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/package.json @@ -0,0 +1,28 @@ +{ + "name": "cordova-plugin-whitelist", + "version": "1.2.1", + "description": "Cordova Whitelist Plugin", + "cordova": { + "platforms": [ + "android" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/apache/cordova-plugin-whitelist" + }, + "keywords": [ + "cordova", + "whitelist", + "ecosystem:cordova", + "cordova-android" + ], + "engines": [ + { + "name": "cordova-android", + "version": ">=4.0.0" + } + ], + "author": "Apache Software Foundation", + "license": "Apache 2.0" +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/cordova-plugin-whitelist/plugin.xml ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/cordova-plugin-whitelist/plugin.xml b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/plugin.xml new file mode 100644 index 0000000..a4f49a8 --- /dev/null +++ b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/plugin.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. +--> + +<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" + id="cordova-plugin-whitelist" + version="1.2.1"> + <name>Whitelist</name> + <description>Cordova Network Whitelist Plugin</description> + <license>Apache 2.0</license> + <keywords>cordova,whitelist,policy</keywords> + + <engines> + <engine name="cordova-android" version=">=4.0.0" /> + </engines> + + <platform name="android"> + <config-file target="res/xml/config.xml" parent="/*"> + <feature name="Whitelist" > + <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin"/> + <param name="onload" value="true" /> + </feature> + </config-file> + + <source-file src="src/android/WhitelistPlugin.java" target-dir="src/org/apache/cordova/whitelist" /> + + <js-module src="whitelist.js" name="whitelist"> + <runs /> + </js-module> + <info> + This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. + </info> + </platform> + + + +</plugin> http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java new file mode 100644 index 0000000..4e4f57e --- /dev/null +++ b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java @@ -0,0 +1,161 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. +*/ + +package org.apache.cordova.whitelist; + +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.ConfigXmlParser; +import org.apache.cordova.Whitelist; +import org.xmlpull.v1.XmlPullParser; + +import android.content.Context; +import android.util.Log; + +public class WhitelistPlugin extends CordovaPlugin { + private static final String LOG_TAG = "WhitelistPlugin"; + private Whitelist allowedNavigations; + private Whitelist allowedIntents; + private Whitelist allowedRequests; + + // Used when instantiated via reflection by PluginManager + public WhitelistPlugin() { + } + // These can be used by embedders to allow Java-configuration of whitelists. + public WhitelistPlugin(Context context) { + this(new Whitelist(), new Whitelist(), null); + new CustomConfigXmlParser().parse(context); + } + public WhitelistPlugin(XmlPullParser xmlParser) { + this(new Whitelist(), new Whitelist(), null); + new CustomConfigXmlParser().parse(xmlParser); + } + public WhitelistPlugin(Whitelist allowedNavigations, Whitelist allowedIntents, Whitelist allowedRequests) { + if (allowedRequests == null) { + allowedRequests = new Whitelist(); + allowedRequests.addWhiteListEntry("file:///*", false); + allowedRequests.addWhiteListEntry("data:*", false); + } + this.allowedNavigations = allowedNavigations; + this.allowedIntents = allowedIntents; + this.allowedRequests = allowedRequests; + } + @Override + public void pluginInitialize() { + if (allowedNavigations == null) { + allowedNavigations = new Whitelist(); + allowedIntents = new Whitelist(); + allowedRequests = new Whitelist(); + new CustomConfigXmlParser().parse(webView.getContext()); + } + } + + private class CustomConfigXmlParser extends ConfigXmlParser { + @Override + public void handleStartTag(XmlPullParser xml) { + String strNode = xml.getName(); + if (strNode.equals("content")) { + String startPage = xml.getAttributeValue(null, "src"); + allowedNavigations.addWhiteListEntry(startPage, false); + } else if (strNode.equals("allow-navigation")) { + String origin = xml.getAttributeValue(null, "href"); + if ("*".equals(origin)) { + allowedNavigations.addWhiteListEntry("http://*/*", false); + allowedNavigations.addWhiteListEntry("https://*/*", false); + allowedNavigations.addWhiteListEntry("data:*", false); + } else { + allowedNavigations.addWhiteListEntry(origin, false); + } + } else if (strNode.equals("allow-intent")) { + String origin = xml.getAttributeValue(null, "href"); + allowedIntents.addWhiteListEntry(origin, false); + } else if (strNode.equals("access")) { + String origin = xml.getAttributeValue(null, "origin"); + String subdomains = xml.getAttributeValue(null, "subdomains"); + boolean external = (xml.getAttributeValue(null, "launch-external") != null); + if (origin != null) { + if (external) { + Log.w(LOG_TAG, "Found <access launch-external> within config.xml. Please use <allow-intent> instead."); + allowedIntents.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0)); + } else { + if ("*".equals(origin)) { + allowedRequests.addWhiteListEntry("http://*/*", false); + allowedRequests.addWhiteListEntry("https://*/*", false); + } else { + allowedRequests.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0)); + } + } + } + } + } + @Override + public void handleEndTag(XmlPullParser xml) { + } + } + + @Override + public Boolean shouldAllowNavigation(String url) { + if (allowedNavigations.isUrlWhiteListed(url)) { + return true; + } + return null; // Default policy + } + + @Override + public Boolean shouldAllowRequest(String url) { + if (Boolean.TRUE == shouldAllowNavigation(url)) { + return true; + } + if (allowedRequests.isUrlWhiteListed(url)) { + return true; + } + return null; // Default policy + } + + @Override + public Boolean shouldOpenExternalUrl(String url) { + if (allowedIntents.isUrlWhiteListed(url)) { + return true; + } + return null; // Default policy + } + + public Whitelist getAllowedNavigations() { + return allowedNavigations; + } + + public void setAllowedNavigations(Whitelist allowedNavigations) { + this.allowedNavigations = allowedNavigations; + } + + public Whitelist getAllowedIntents() { + return allowedIntents; + } + + public void setAllowedIntents(Whitelist allowedIntents) { + this.allowedIntents = allowedIntents; + } + + public Whitelist getAllowedRequests() { + return allowedRequests; + } + + public void setAllowedRequests(Whitelist allowedRequests) { + this.allowedRequests = allowedRequests; + } +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/cordova-plugin-whitelist/whitelist.js ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/cordova-plugin-whitelist/whitelist.js b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/whitelist.js new file mode 100644 index 0000000..74d7a99 --- /dev/null +++ b/tests/cdv-test-project/plugins/cordova-plugin-whitelist/whitelist.js @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * +*/ + +if (!document.querySelector('meta[http-equiv=Content-Security-Policy]')) { + var msg = 'No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.'; + console.error(msg); + setInterval(function() { + console.warn(msg); + }, 10000); +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/fetch.json ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/fetch.json b/tests/cdv-test-project/plugins/fetch.json new file mode 100644 index 0000000..bfc05e7 --- /dev/null +++ b/tests/cdv-test-project/plugins/fetch.json @@ -0,0 +1,10 @@ +{ + "cordova-plugin-whitelist": { + "source": { + "type": "registry", + "id": "cordova-plugin-whitelist@1" + }, + "is_top_level": true, + "variables": {} + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/plugins/osx.json ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/plugins/osx.json b/tests/cdv-test-project/plugins/osx.json new file mode 100644 index 0000000..2270d61 --- /dev/null +++ b/tests/cdv-test-project/plugins/osx.json @@ -0,0 +1,15 @@ +{ + "prepare_queue": { + "installed": [], + "uninstalled": [] + }, + "config_munge": { + "files": {} + }, + "installed_plugins": { + "cordova-plugin-whitelist": { + "PACKAGE_NAME": "org.apache.cordova.test" + } + }, + "dependent_plugins": {} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/res/test-64x64.png ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/res/test-64x64.png b/tests/cdv-test-project/res/test-64x64.png new file mode 100644 index 0000000..430bdc5 Binary files /dev/null and b/tests/cdv-test-project/res/test-64x64.png differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/www/css/index.css ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/www/css/index.css b/tests/cdv-test-project/www/css/index.css new file mode 100644 index 0000000..51daa79 --- /dev/null +++ b/tests/cdv-test-project/www/css/index.css @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +* { + -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ +} + +body { + -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ + -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ + -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ + background-color:#E4E4E4; + background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + background-image:-webkit-gradient( + linear, + left top, + left bottom, + color-stop(0, #A7A7A7), + color-stop(0.51, #E4E4E4) + ); + background-attachment:fixed; + font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif; + font-size:12px; + height:100%; + margin:0px; + padding:0px; + text-transform:uppercase; + width:100%; +} + +/* Portrait layout (default) */ +.app { + background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */ + position:absolute; /* position in the center of the screen */ + left:50%; + top:50%; + height:50px; /* text area height */ + width:225px; /* text area width */ + text-align:center; + padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */ + margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */ + /* offset horizontal: half of text area width */ +} + +/* Landscape layout (with min-width) */ +@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { + .app { + background-position:left center; + padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */ + margin:-90px 0px 0px -198px; /* offset vertical: half of image height */ + /* offset horizontal: half of image width and text area width */ + } +} + +h1 { + font-size:24px; + font-weight:normal; + margin:0px; + overflow:visible; + padding:0px; + text-align:center; +} + +.event { + border-radius:4px; + -webkit-border-radius:4px; + color:#FFFFFF; + font-size:12px; + margin:0px 30px; + padding:2px 0px; +} + +.event.listening { + background-color:#333333; + display:block; +} + +.event.received { + background-color:#4B946A; + display:none; +} + +@keyframes fade { + from { opacity: 1.0; } + 50% { opacity: 0.4; } + to { opacity: 1.0; } +} + +@-webkit-keyframes fade { + from { opacity: 1.0; } + 50% { opacity: 0.4; } + to { opacity: 1.0; } +} + +.blink { + animation:fade 3000ms infinite; + -webkit-animation:fade 3000ms infinite; +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/www/img/logo.png ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/www/img/logo.png b/tests/cdv-test-project/www/img/logo.png new file mode 100644 index 0000000..9519e7d Binary files /dev/null and b/tests/cdv-test-project/www/img/logo.png differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/www/index.html ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/www/index.html b/tests/cdv-test-project/www/index.html new file mode 100644 index 0000000..646f9cb --- /dev/null +++ b/tests/cdv-test-project/www/index.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. +--> +<html> + <head> + <!-- + Customize this policy to fit your own app's needs. For more guidance, see: + https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy + Some notes: + * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication + * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly + * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this: + * Enable inline JS: add 'unsafe-inline' to default-src + --> + <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> + <meta name="format-detection" content="telephone=no"> + <meta name="msapplication-tap-highlight" content="no"> + <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> + <link rel="stylesheet" type="text/css" href="css/index.css"> + <title>Hello World</title> + </head> + <body> + <div class="app"> + <h1>Apache Cordova</h1> + <div id="deviceready" class="blink"> + <p class="event listening">Connecting to Device</p> + <p class="event received">Device is Ready</p> + </div> + </div> + <script type="text/javascript" src="cordova.js"></script> + <script type="text/javascript" src="js/index.js"></script> + </body> +</html> http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/cdv-test-project/www/js/index.js ---------------------------------------------------------------------- diff --git a/tests/cdv-test-project/www/js/index.js b/tests/cdv-test-project/www/js/index.js new file mode 100644 index 0000000..c31cd83 --- /dev/null +++ b/tests/cdv-test-project/www/js/index.js @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 app = { + // Application Constructor + initialize: function() { + this.bindEvents(); + }, + // Bind Event Listeners + // + // Bind any events that are required on startup. Common events are: + // 'load', 'deviceready', 'offline', and 'online'. + bindEvents: function() { + document.addEventListener('deviceready', this.onDeviceReady, false); + }, + // deviceready Event Handler + // + // The scope of 'this' is the event. In order to call the 'receivedEvent' + // function, we must explicitly call 'app.receivedEvent(...);' + onDeviceReady: function() { + app.receivedEvent('deviceready'); + }, + // Update DOM on a Received Event + receivedEvent: function(id) { + var parentElement = document.getElementById(id); + var listeningElement = parentElement.querySelector('.listening'); + var receivedElement = parentElement.querySelector('.received'); + + listeningElement.setAttribute('style', 'display:none;'); + receivedElement.setAttribute('style', 'display:block;'); + + console.log('Received Event: ' + id); + } +}; + +app.initialize(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/8ac659c7/tests/spec/platform.spec.js ---------------------------------------------------------------------- diff --git a/tests/spec/platform.spec.js b/tests/spec/platform.spec.js new file mode 100644 index 0000000..5738f34 --- /dev/null +++ b/tests/spec/platform.spec.js @@ -0,0 +1,80 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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 shell = require('shelljs'), + spec = __dirname, + path = require('path'), + util = require('util'), + fs = require('fs'); + + var cordova_bin = path.join(spec, '../..', 'bin'); + var test_projectPath = path.join(spec, '../', 'cdv-test-project'); + var test_platformPath = path.join(test_projectPath, 'platforms', 'osx'); + + var tmp = require('tmp').dirSync().name; + +function initProject() { + // remove existing folder + var pPath = path.join(test_projectPath, 'platforms'); + shell.rm('-rf', pPath); +} + +describe('platform add', function() { + + beforeEach(function() { + initProject(); + + shell.cd(test_projectPath); + var command = 'cordova platform add ../../'; + console.log('executing "%s" in "%s"', command, shell.pwd()); + var return_code = shell.exec(command, { silent: false}).code; + expect(return_code).toBe(0); + }); + + it('should have a config.xml', function() { + var configXmlPath = path.join(test_platformPath, 'HelloCordova', 'config.xml'); + expect(fs.existsSync(configXmlPath)).toBe(true); + }); + + it('should have the correct icons', function() { + + var platformIcons = [ + {name: 'icon-16x16.png', width: 16, height: 16}, + {name: 'icon-32x32.png', width: 32, height: 32}, + {name: 'icon-64x64.png', width: 64, height: 64}, + {name: 'icon-128x128.png', width: 128, height: 128}, + {name: 'icon-256x256.png', width: 256, height: 256}, + {name: 'icon-512x512.png', width: 512, height: 512} + ]; + + var appIconsPath = path.join(test_platformPath, 'HelloCordova','Images.xcassets','AppIcon.appiconset'); + var srcIcon = path.join(test_projectPath, 'res', 'test-64x64.png'); + platformIcons.forEach(function(iconDef) { + var iconPath = path.join(appIconsPath, iconDef.name); + expect(fs.existsSync(iconPath)).toBe(true); + + // check if the icons are the same as the one specified in the config.xml + var cmd = util.format('cmp "%s" "%s"', srcIcon, iconPath); + var return_code = shell.exec(cmd, { silent: false}).code; + expect(return_code).toBe(0); + + }); + }); + +}); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org