This is an automated email from the ASF dual-hosted git repository. erisu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-mobile-spec.git
The following commit(s) were added to refs/heads/master by this push: new cbcb4e3 chore!: clean up plugins (and extract cordova-plugin-whitelist-tests) (#203) cbcb4e3 is described below commit cbcb4e33156cfd7776beeaee09400c11dc3ba2ae Author: Jan Piotrowski <piotrowski+...@gmail.com> AuthorDate: Mon Feb 24 14:17:19 2025 +0100 chore!: clean up plugins (and extract cordova-plugin-whitelist-tests) (#203) * fix and cleanup cordova-plugin-echo * cleanup and fix cordova-plugin-mobilespec-tests * package.json for cordova-plugin-whitelist (that is actually a test plugin) * fix plugin add commands to work with paths with spaces * re-enable cordova-plugin-mobilespec-tests, cordova-plugin-echo and cordova-plugin-whitelist-tests * fix bridge.tests.js (technically, make it run at least) * remove cordova-plugin-whitelist (replaced by https://github.com/apache/cordova-plugin-whitelist/pull/38) * clean up searchpaths and don't manually try to add cordova-plugin-whitelist-tests * style: remove trailing spaces * chore: update author and set plugin packages as private * feat!: remove deprecated osx platform from echo plugin * chore: fix plugin name typo --------- Co-authored-by: エリス <er...@apache.org> --- README.md | 2 +- cordova-plugin-echo/README.md | 32 +++- cordova-plugin-echo/docs/echo.md | 50 ----- cordova-plugin-echo/package.json | 15 ++ cordova-plugin-echo/plugin.xml | 23 +-- cordova-plugin-mobilespec-tests/package.json | 15 ++ cordova-plugin-mobilespec-tests/plugin.xml | 6 +- .../tests/bridge.tests.js | 2 +- .../tests/whitelist.tests.js | 211 --------------------- cordova-plugin-whitelist/README.md | 51 ----- cordova-plugin-whitelist/plugin.xml | 59 ------ .../src/android/WhitelistAPI.java | 90 --------- cordova-plugin-whitelist/src/ubuntu/whitelist.cpp | 35 ---- cordova-plugin-whitelist/src/ubuntu/whitelist.h | 46 ----- cordova-plugin-whitelist/www/whitelist.js | 34 ---- createmobilespec/createmobilespec.js | 18 +- 16 files changed, 70 insertions(+), 619 deletions(-) diff --git a/README.md b/README.md index 42c4118..2940b7a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ This repository has 3 parts: 1. This main folder is a Cordova app "template" (`config.xml` and `www`) that includes implementations of various functionalities that Cordova supports (battery, events, keyboard, lazyloadjs, splashscreens, sql, storage, misc) that can manually be tested, some benchmarks, and a link to the automated and manual tests installed plugins offer (`cdvtests/index.html`). -2. There are 4 plugins as well: [`cordova-plugin-echo`](cordova-plugin-echo) ("plugin implementation of the Echo function to test the bridge"), [`cordova-plugin-mobilespec-tests`](cordova-plugin-mobilespec-tests) ("Cordova Non Plugin Auto Tests"), [`cordova-plugin-thirdparty-tests`](cordova-plugin-thirdparty-tests) ("Tests for popular third-party plugins") and [`cordova-plugin-whitelist`](cordova-plugin-whitelist) (TODO). +2. There are 2 plugins as well: [`cordova-plugin-echo`](cordova-plugin-echo) ("plugin implementation of the Echo function to test the bridge"), [`cordova-plugin-mobilespec-tests`](cordova-plugin-mobilespec-tests) ("Cordova Non Plugin Auto Tests"). 3. The `createmobilespec` folder contains a script/CLI to create a Cordova app diff --git a/cordova-plugin-echo/README.md b/cordova-plugin-echo/README.md index 0b0e8f9..4d19d39 100644 --- a/cordova-plugin-echo/README.md +++ b/cordova-plugin-echo/README.md @@ -19,7 +19,35 @@ # --> -cordova-plugin-echo ------------------------- +# cordova-plugin-echo This is a plugin implementation of the Echo function to test the bridge. It is currently used by Mobile Spec to test and benchmark the bridge. + +## Echo + +> The `echo` object provides an interface for testing the bridge. It +> sends any data received back across the bridge unmodifed. This +> allows the bridge modes to be tested and benchmarked. + +### Methods + +- cordova.echo.echo +- cordova.echo.echoAsync +- cordova.echo.echoArrayBuffer +- cordova.echo.echoMultiPart + +#### cordova.echo.echo + +Echos string data in the same thread. + +#### cordova.echo.echoAsync + +Echos string data in a new UI thread. + +#### cordova.echo.echoArrayBuffer + +Echos base64 encoded data in the same thread. + +#### cordova.echo.echoMultiPart + +Echos a multipart message in the same thread. \ No newline at end of file diff --git a/cordova-plugin-echo/docs/echo.md b/cordova-plugin-echo/docs/echo.md deleted file mode 100644 index 6fe0f8f..0000000 --- a/cordova-plugin-echo/docs/echo.md +++ /dev/null @@ -1,50 +0,0 @@ ---- - 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. ---- - -Echo -========= - -> The `echo` object provides an interface for testing the bridge. It -> sends any data received back across the bridge unmodifed. This -> allows the bridge modes to be tested and benchmarked. - -Methods -------- - -- cordova.echo.echo -- cordova.echo.echoAsync -- cordova.echo.echoArrayBuffer -- cordova.echo.echoMultiPart - -### cordova.echo.echo - -Echos string data in the same thread. - -### cordova.echo.echoAsync - -Echos string data in a new UI thread. - -### cordova.echo.echoArrayBuffer - -Echos base64 encoded data in the same thread. - -### cordova.echo.echoMultiPart - -Echos a multipart message in the same thread. - diff --git a/cordova-plugin-echo/package.json b/cordova-plugin-echo/package.json new file mode 100644 index 0000000..7f3f4a6 --- /dev/null +++ b/cordova-plugin-echo/package.json @@ -0,0 +1,15 @@ +{ + "name": "cordova-plugin-echo", + "version": "0.1.0", + "private": true, + "description": "", + "cordova": { + "id": "cordova-plugin-echo", + "platforms": [] + }, + "keywords": [ + "ecosystem:cordova" + ], + "author": "Apache Software Foundation", + "license": "Apache 2.0" +} diff --git a/cordova-plugin-echo/plugin.xml b/cordova-plugin-echo/plugin.xml index d175a07..533cc4d 100644 --- a/cordova-plugin-echo/plugin.xml +++ b/cordova-plugin-echo/plugin.xml @@ -20,7 +20,7 @@ --> <plugin xmlns="http://cordova.apache.org/ns/plugins/1.0" - id="org.apache.cordova.test.echo" + id="cordova-plugin-echo" version="0.1.0"> <name>Echo</name> @@ -41,16 +41,6 @@ <source-file src="src/android/Echo.java" target-dir="src/org/apache/cordova/test" /> </platform> - <!-- amazon-fireos --> - <platform name="amazon-fireos"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="Echo" > - <param name="android-package" value="org.apache.cordova.test.Echo"/> - </feature> - </config-file> - - <source-file src="src/android/Echo.java" target-dir="src/org/apache/cordova/test" /> - </platform> <!-- ios --> <platform name="ios"> <config-file target="config.xml" parent="/*"> @@ -60,15 +50,4 @@ </config-file> <source-file src="src/ios/CDVEcho.m" /> </platform> - - <!-- osx --> - <platform name="osx"> - <config-file target="config.xml" parent="/*"> - <feature name="Echo"> - <param name="ios-package" value="CDVEcho"/> - </feature> - </config-file> - <source-file src="src/ios/CDVEcho.m" /> - </platform> - </plugin> diff --git a/cordova-plugin-mobilespec-tests/package.json b/cordova-plugin-mobilespec-tests/package.json new file mode 100644 index 0000000..8b22124 --- /dev/null +++ b/cordova-plugin-mobilespec-tests/package.json @@ -0,0 +1,15 @@ +{ + "name": "cordova-plugin-mobilespec-tests", + "version": "1.0.0", + "private": true, + "description": "", + "cordova": { + "id": "cordova-plugin-mobilespec-tests", + "platforms": [] + }, + "keywords": [ + "ecosystem:cordova" + ], + "author": "Apache Software Foundation", + "license": "Apache 2.0" +} diff --git a/cordova-plugin-mobilespec-tests/plugin.xml b/cordova-plugin-mobilespec-tests/plugin.xml index bf87049..20981a8 100644 --- a/cordova-plugin-mobilespec-tests/plugin.xml +++ b/cordova-plugin-mobilespec-tests/plugin.xml @@ -20,8 +20,7 @@ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:rim="http://www.blackberry.com/ns/widgets" - id="org.apache.cordova.mobilespec.tests" + id="cordova-plugin-mobilespec-tests" version="1.0.0"> <name>Cordova Non Plugin Auto Tests</name> <license>Apache 2.0</license> @@ -41,9 +40,6 @@ <js-module src="tests/storage.tests.js" name="storage.tests"> </js-module> - <js-module src="tests/whitelist.tests.js" name="whitelist.tests"> - </js-module> - <js-module src="tests/input.tests.js" name="input.tests"> </js-module> diff --git a/cordova-plugin-mobilespec-tests/tests/bridge.tests.js b/cordova-plugin-mobilespec-tests/tests/bridge.tests.js index 954f41e..ee76ff5 100644 --- a/cordova-plugin-mobilespec-tests/tests/bridge.tests.js +++ b/cordova-plugin-mobilespec-tests/tests/bridge.tests.js @@ -19,7 +19,7 @@ * */ exports.defineAutoTests = function () { - describe('Bridge', function (done) { + describe('Bridge', function () { var frame; afterEach(function () { if (frame) { diff --git a/cordova-plugin-mobilespec-tests/tests/whitelist.tests.js b/cordova-plugin-mobilespec-tests/tests/whitelist.tests.js deleted file mode 100644 index 90a660c..0000000 --- a/cordova-plugin-mobilespec-tests/tests/whitelist.tests.js +++ /dev/null @@ -1,211 +0,0 @@ -cordova.define("org.apache.cordova.mobilespec.tests.whitelist.tests", function(require, exports, module) { /* - * - * 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. - * - */ - -exports.defineAutoTests = function () { - - var isWindowsPhone = cordova.platformId == 'windowsphone'; - var isWindows = (cordova.platformId === "windows") || (cordova.platformId === "windows8") - var isIOS = (cordova.platformId === "ios"); - - describe('Whitelist API (cordova.whitelist)', function () { - - it("should exist", function () { - expect(cordova.whitelist).toBeDefined(); - }); - - describe("Match function", function () { - function expectMatchWithResult(result) { - return (function (url, patterns, description) { - description = description || ((result ? "should accept " : "should reject ") + url + " for " + JSON.stringify(patterns)); - this.result = result; - - describe("Match function", function () { - // Timeout is 7.5 seconds to allow physical devices enough - // time to query the response. This is important for some - // Android devices. - var originalTimeout, - cb; - - if (isWindows || isWindowsPhone || isIOS) { - pending(); - } - - beforeEach(function (done) { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 7500; - cb = jasmine.createSpy('spy').and.callFake(function () { - done(); - }); - cordova.whitelist.match(url, patterns, cb); - }); - - afterEach(function () { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - it(description, function () { - expect(cb).toHaveBeenCalledWith(result); - }); - }); - }); - } - - var itShouldMatch = expectMatchWithResult(true); - var itShouldNotMatch = expectMatchWithResult(false); - - itShouldMatch('http://www.apache.org/', ['*'], "should accept any domain for *"); - itShouldNotMatch('http://www.apache.org/', [], "should not accept any domain for []"); - - itShouldMatch('http://apache.org/', ['http://*.apache.org']); - itShouldMatch('http://www.apache.org/', ['http://*.apache.org']); - itShouldMatch('http://www.apache.org/some/path', ['http://*.apache.org']); - itShouldMatch('http://some.domain.under.apache.org/', ['http://*.apache.org']); - itShouldMatch('http://user:p...@apache.org/', ['http://*.apache.org']); - itShouldMatch('http://user:p...@www.apache.org/', ['http://*.apache.org']); - itShouldMatch('http://www.apache.org/?some=params', ['http://*.apache.org']); - itShouldNotMatch('http://apache.com/', ['http://*.apache.org']); - itShouldNotMatch('http://www.evil.com/?url=www.apache.org', ['http://*.apache.org']); - itShouldNotMatch('http://www.evil.com/?url=http://www.apache.org', ['http://*.apache.org']); - itShouldNotMatch('http://www.evil.com/?url=http%3A%2F%2Fwww%2Eapache%2Eorg', ['http://*.apache.org']); - itShouldNotMatch('https://apache.org/', ['http://*.apache.org']); - itShouldNotMatch('http://www.apache.org:p...@evil.com/', ['http://*.apache.org']); - itShouldNotMatch('http://www.apache.org.evil.com/', ['http://*.apache.org']); - - itShouldMatch('http://www.apache.org/', ['http://*.apache.org', 'https://*.apache.org']); - itShouldMatch('https://www.apache.org/', ['http://*.apache.org', 'https://*.apache.org']); - itShouldNotMatch('ftp://www.apache.org/', ['http://*.apache.org', 'https://*.apache.org']); - itShouldNotMatch('http://www.apache.com/', ['http://*.apache.org', 'https://*.apache.org']); - - itShouldMatch('http://www.apache.org/', ['http://www.apache.org']); - itShouldNotMatch('http://build.apache.org/', ['http://www.apache.org']); - itShouldNotMatch('http://apache.org/', ['http://www.apache.org']); - - itShouldMatch('http://www.apache.org/', ['http://*/*']); - itShouldMatch('http://www.apache.org/foo/bar.html', ['http://*/*']); - - itShouldMatch('http://www.apache.org/foo', ['http://*/foo*']); - itShouldMatch('http://www.apache.org/foo/bar.html', ['http://*/foo*']); - itShouldNotMatch('http://www.apache.org/', ['http://*/foo*']); - - itShouldMatch('file:///foo', ['file:///*']); - - itShouldMatch('file:///foo', ['file:///foo*']); - itShouldMatch('file:///foo/bar.html', ['file:///foo*']); - itShouldNotMatch('file:///foo.html', []); - itShouldNotMatch('http://www.apache.org/etc/foo', ['http://www.apache.org/foo*']); - itShouldNotMatch('http://www.apache.org/foo', ['file:///foo*']); - - itShouldMatch('http://www.apache.org/', ['*://www.apache.org/*']); - itShouldMatch('https://www.apache.org/', ['*://www.apache.org/*']); - itShouldMatch('ftp://www.apache.org/', ['*://www.apache.org/*']); - itShouldMatch('file://www.apache.org/', ['*://www.apache.org/*']); - if (cordova.platformId == 'android') - itShouldMatch('content://www.apache.org/', ['*://www.apache.org/*']); - itShouldMatch('foo://www.apache.org/', ['*://www.apache.org/*']); - itShouldNotMatch('http://www.apache.com/', ['*://www.apache.org/*']); - - itShouldMatch('http://www.apache.org/', ['*.apache.org']); - itShouldMatch('https://www.apache.org/', ['*.apache.org']); - itShouldNotMatch('ftp://www.apache.org/', ['*.apache.org']); - - itShouldMatch('http://www.apache.org:81/', ['http://www.apache.org:81/*']); - itShouldMatch('http://user:p...@www.apache.org:81/foo/bar.html', ['http://www.apache.org:81/*']); - itShouldNotMatch('http://www.apache.org:80/', ['http://www.apache.org:81/*']); - itShouldNotMatch('http://www.apache.org/', ['http://www.apache.org:81/*']); - itShouldNotMatch('http://www.apache.org:foo/', ['http://www.apache.org:81/*']); - itShouldNotMatch('http://www.apache.org:8...@www.apache.org/', ['http://www.apache.org:81/*']); - itShouldNotMatch('http://www.apache.org:8...@www.evil.com/', ['http://www.apache.org:81/*']); - - itShouldMatch('http://www.APAche.org/', ['*.apache.org']); - itShouldMatch('http://WWw.apache.org/', ['*.apache.org']); - itShouldMatch('http://www.apache.org/', ['*.APACHE.ORG']); - itShouldMatch('HTTP://www.apache.org/', ['*.apache.org']); - itShouldMatch('HTTP://www.apache.org/', ['http://*.apache.org']); - itShouldMatch('http://www.apache.org/', ['HTTP://*.apache.org']); - - itShouldMatch('http://www.apache.org/foo/', ['*://*.apache.org/foo/*']); - itShouldMatch('http://www.apache.org/foo/bar', ['*://*.apache.org/foo/*']); - itShouldNotMatch('http://www.apache.org/bar/foo/', ['*://*.apache.org/foo/*']); - itShouldNotMatch('http://www.apache.org/Foo/', ['*://*.apache.org/foo/*']); - itShouldNotMatch('http://www.apache.org/Foo/bar', ['*://*.apache.org/foo/*']); - }); - - describe("Test function", function () { - function expectTestWithResult(result) { - return (function (url, description) { - description = description || ((result ? "should accept " : "should reject ") + url); - - describe("Test function", function () { - if (isWindows || isWindowsPhone || isIOS) { - pending(); - } - - var cb, - originalTimeout; - - beforeEach(function (done) { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 7500; - cb = jasmine.createSpy('spy').and.callFake(function (){ - done(); - }); - cordova.whitelist.test(url, cb); - }); - - afterEach(function () { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - it(description, function () { - expect(cb).toHaveBeenCalledWith(result); - }); - }); - }); - } - - var itShouldAccept = expectTestWithResult(true); - var itShouldReject = expectTestWithResult(false); - - it("should exist", function () { - expect(cordova.whitelist.test).toBeDefined(); - expect(typeof cordova.whitelist.test).toBe("function"); - }); - - itShouldAccept('http://apache.org'); - itShouldAccept('http://apache.org/'); - itShouldAccept('http://www.apache.org/'); - itShouldAccept('http://www.apache.org/some/path'); - itShouldAccept('http://some.domain.under.apache.org/'); - itShouldAccept('http://user:p...@apache.org/'); - itShouldAccept('http://user:p...@www.apache.org/'); - itShouldAccept('https://www.apache.org/'); - itShouldReject('ftp://www.apache.org/'); - itShouldReject('http://www.apache.com/'); - itShouldReject('http://www.apache.org:p...@evil.com/'); - itShouldReject('http://www.apache.org.evil.com/'); - itShouldAccept('file:///foo'); - if (cordova.platformId == 'android') - itShouldReject('content:///foo'); - }); - }); -} - -}); diff --git a/cordova-plugin-whitelist/README.md b/cordova-plugin-whitelist/README.md deleted file mode 100644 index f7ef371..0000000 --- a/cordova-plugin-whitelist/README.md +++ /dev/null @@ -1,51 +0,0 @@ ---- - 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. ---- - -Whitelist -========= - -> The `whitelist` object provides an interface for testing whether arbitrary -> URLs are allowed by the currently active configuration, or would be allowed -> by a given set of whitelist patterns. - -Methods -------- - -- cordova.whitelist.match -- cordova.whitelist.test - -### cordova.whitelist.match - -Indicates whether a given URL would be allowed by a set of Whitelist URL -patterns. - - cordova.whitelist.match(url, patterns, callback); - -`callback` will be invoked with a boolean argument indicating whether the -url matches the set of patterns. - -### cordova.whitelist.test - -Indicates whether a given URL would be allowed by the current application -configuration. - - cordova.whitelist.test(url, callback); - -`callback` will be invoked with a boolean argument indicating whether the -url is currently whitelisted. diff --git a/cordova-plugin-whitelist/plugin.xml b/cordova-plugin-whitelist/plugin.xml deleted file mode 100644 index 89e35f3..0000000 --- a/cordova-plugin-whitelist/plugin.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?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://cordova.apache.org/ns/plugins/1.0" - id="org.apache.cordova.test.whitelist" - version="0.1.0"> - <name>Whitelist</name> - - <js-module src="www/whitelist.js" name="whitelist"> - <clobbers target="cordova.whitelist" /> - </js-module> - - <!-- android --> - <platform name="android"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="WhitelistAPI" > - <param name="android-package" value="org.apache.cordova.test.WhitelistAPI"/> - </feature> - </config-file> - - <source-file src="src/android/WhitelistAPI.java" target-dir="src/org/apache/cordova/test" /> - </platform> - - <!-- amazon-fireos --> - <platform name="amazon-fireos"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="WhitelistAPI" > - <param name="android-package" value="org.apache.cordova.test.WhitelistAPI"/> - </feature> - </config-file> - - <source-file src="src/android/WhitelistAPI.java" target-dir="src/org/apache/cordova/test" /> - </platform> - - <!-- ubuntu --> - <platform name="ubuntu"> - <header-file src="src/ubuntu/whitelist.h" /> - <source-file src="src/ubuntu/whitelist.cpp" /> - </platform> - -</plugin> diff --git a/cordova-plugin-whitelist/src/android/WhitelistAPI.java b/cordova-plugin-whitelist/src/android/WhitelistAPI.java deleted file mode 100644 index 934ffb9..0000000 --- a/cordova-plugin-whitelist/src/android/WhitelistAPI.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - 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.test; - -import org.apache.cordova.Whitelist; -import org.apache.cordova.Config; - -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.PluginResult; -import org.json.JSONArray; -import org.json.JSONException; - -import org.apache.cordova.PluginManager; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class WhitelistAPI extends CordovaPlugin { - /** - * Executes the request and returns PluginResult. - * - * @param action The action to execute. - * @param args JSONArry of arguments for the plugin. - * @param callbackContext The callback id used when calling back into JavaScript. - * @return True if the action was valid, false if not. - */ - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("URLMatchesPatterns")) { - String url = args.getString(0); - JSONArray patterns = args.getJSONArray(1); - Whitelist whitelist = new Whitelist(); - for (int i=0; i < patterns.length(); i++) { - String pattern = patterns.getString(i); - whitelist.addWhiteListEntry(pattern, false); - } - boolean isAllowed = whitelist.isUrlWhiteListed(url); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isAllowed)); - return true; - } else if (action.equals("URLIsAllowed")) { - String url = args.getString(0); - /* This code exists for compatibility between 3.x and 4.x versions of Cordova. - * Previously the CordovaWebView class had a method, getWhitelist, which would - * return a Whitelist object. Since the fixed whitelist is removed in Cordova 4.x, - * the correct call now is to shouldAllowRequest from the plugin manager. - */ - Boolean isAllowed = null; - try { - Method isUrlWhiteListed = Config.class.getDeclaredMethod("isUrlWhitelisted", String.class); - isAllowed = (Boolean)isUrlWhiteListed.invoke(url); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - if (isAllowed == null) { - try { - Method gpm = webView.getClass().getMethod("getPluginManager"); - PluginManager pm = (PluginManager)gpm.invoke(webView); - Method isAllowedMethod = pm.getClass().getMethod("shouldAllowRequest", String.class); - isAllowed = (Boolean)isAllowedMethod.invoke(pm, url); - if (isAllowed == null) { - isAllowed = false; - } - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } - - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isAllowed)); - return true; - } - return false; - } -} diff --git a/cordova-plugin-whitelist/src/ubuntu/whitelist.cpp b/cordova-plugin-whitelist/src/ubuntu/whitelist.cpp deleted file mode 100644 index 4d37a61..0000000 --- a/cordova-plugin-whitelist/src/ubuntu/whitelist.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2014 Canonical Ltd. - * - * 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. - */ - -#include "whitelist.h" -#include <cordova_whitelist.hpp> - -Whitelist::Whitelist(Cordova *cordova): CPlugin(cordova) { -} - -void Whitelist::URLMatchesPatterns(int scId, int ecId, const QString &url, const QList<QString> &patterns) { - CordovaInternal::WhiteList whitelist; - for (const QString &pattern: patterns) { - whitelist.addWhiteListEntry(pattern, false); - } - bool isAllowed = whitelist.isUrlWhiteListed(url); - cb(scId, isAllowed); -} - -void Whitelist::URLIsAllowed(int scId, int ecId, const QString &url) { - bool isAllowed = m_cordova->config().whitelist().isUrlWhiteListed(url); - cb(scId, isAllowed); -} diff --git a/cordova-plugin-whitelist/src/ubuntu/whitelist.h b/cordova-plugin-whitelist/src/ubuntu/whitelist.h deleted file mode 100644 index ecf2228..0000000 --- a/cordova-plugin-whitelist/src/ubuntu/whitelist.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014 Canonical Ltd. - * - * 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. - */ - -#ifndef WHITELIST_HKJBNNB90NM53452 -#define WHITELIST_HKJBNNB90NM53452 - -#include <QtCore> - -#include <cplugin.h> -#include <cordova.h> - -class Whitelist: public CPlugin { - Q_OBJECT -public: - explicit Whitelist(Cordova *cordova); - - virtual const QString fullName() override { - return Whitelist::fullID(); - } - - virtual const QString shortName() override { - return Whitelist::fullID(); - } - - static const QString fullID() { - return "WhitelistAPI"; - } -public slots: - void URLMatchesPatterns(int scId, int ecId, const QString &url, const QList<QString> &patterns); - void URLIsAllowed(int scId, int ecId, const QString &url); -}; - -#endif diff --git a/cordova-plugin-whitelist/www/whitelist.js b/cordova-plugin-whitelist/www/whitelist.js deleted file mode 100644 index b342c0f..0000000 --- a/cordova-plugin-whitelist/www/whitelist.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * 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 argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'); - -module.exports = { - match: function(url, patterns, callback) { - //argscheck.checkArgs('fF', 'Whitelist.match', arguments); - exec(callback, callback, "WhitelistAPI", "URLMatchesPatterns", [url, patterns]); - }, - test: function(url, callback) { - //argscheck.checkArgs('fF', 'Whitelist.test', arguments); - exec(callback, callback, "WhitelistAPI", "URLIsAllowed", [url]); - } -} diff --git a/createmobilespec/createmobilespec.js b/createmobilespec/createmobilespec.js index 1e0bf85..8ea563a 100755 --- a/createmobilespec/createmobilespec.js +++ b/createmobilespec/createmobilespec.js @@ -64,7 +64,7 @@ function pluginAdd(pluginName, searchPath, extraFlags) { } var command = cli + ' plugin add ' + pluginName; if (fs.existsSync(path.join(searchPath, pluginName, 'plugin.xml'))) { - command = cli + ' plugin add ' + path.join(searchPath, pluginName); + command = cli + ' plugin add "' + path.join(searchPath, pluginName) + '"'; } else if (searchPath && searchPath.length) { command = cli + ' plugin add ' + pluginName + ' --searchpath ' + searchPath; } @@ -188,10 +188,9 @@ var DEFAULT_PLUGINS_OSX = [ ]; // plugin search paths that will override default -// removed 'org.apache.cordova.test.whitelist': mobile_spec_git_dir, var SEARCH_PATHS = { - 'org.apache.cordova.mobilespec.tests': mobile_spec_git_dir, - 'org.apache.cordova.test.echo': mobile_spec_git_dir, + 'cordova-plugin-mobilespec-tests': mobile_spec_git_dir, + 'cordova-plugin-echo': mobile_spec_git_dir, 'cordova-plugin-test-framework': top_dir }; @@ -536,18 +535,13 @@ function installPlugins() { // Install mobilespec tests only if we install default list of plugins // If custom list of plugins is being installed, mobilespec tests can be listed there, if needed if (!argv.plugins) { - //pluginAdd('org.apache.cordova.mobilespec.tests', mobile_spec_git_dir, allPluginFlags); + pluginAdd('cordova-plugin-mobilespec-tests', mobile_spec_git_dir, allPluginFlags); } - //pluginAdd('org.apache.cordova.test.whitelist', mobile_spec_git_dir, allPluginFlags); - pluginAdd('org.apache.cordova.test.echo', mobile_spec_git_dir, allPluginFlags); + pluginAdd('cordoa-plugin-echo', mobile_spec_git_dir, allPluginFlags); pluginAdd('cordova-plugin-test-framework', searchPath, allPluginFlags); pluginAdd('cordova-plugin-device', searchPath, allPluginFlags); - if (argv.android) { - pluginAdd('cordova-plugin-whitelist', searchPath, allPluginFlags); - } - plugins.forEach(function(p) { var sp = SEARCH_PATHS.hasOwnProperty(p) ? SEARCH_PATHS[p] : searchPath; pluginAdd(p, sp, allPluginFlags); @@ -559,7 +553,7 @@ function installPlugins() { plugins.forEach(function(plugin) { var potential_tests_plugin_xml = path.join('plugins', plugin, 'tests', 'plugin.xml'); if (fs.existsSync(potential_tests_plugin_xml)) { - pluginTestPaths.push(path.resolve(path.dirname(potential_tests_plugin_xml))); + pluginTestPaths.push('"' + path.resolve(path.dirname(potential_tests_plugin_xml)) + '"'); } }); pluginAdd(pluginTestPaths.join(' '), null, allPluginFlags); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org