Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 731d227f14 |
+9
-22
@@ -1,23 +1,10 @@
|
||||
# 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.
|
||||
|
||||
root: true
|
||||
extends: '@cordova/eslint-config/browser'
|
||||
|
||||
overrides:
|
||||
- files: [tests/**/*.js]
|
||||
extends: '@cordova/eslint-config/node-tests'
|
||||
extends: semistandard
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
camelcase: off
|
||||
padded-blocks: off
|
||||
operator-linebreak: off
|
||||
no-throw-literal: off
|
||||
+5
-3
@@ -13,8 +13,8 @@ env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION=12
|
||||
- ANDROID_API_LEVEL=29
|
||||
- ANDROID_BUILD_TOOLS_VERSION=29.0.2
|
||||
- ANDROID_API_LEVEL=28
|
||||
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
|
||||
|
||||
language: node_js
|
||||
node_js: 12
|
||||
@@ -23,7 +23,7 @@ node_js: 12
|
||||
|
||||
_ios: &_ios
|
||||
os: osx
|
||||
osx_image: xcode11.6
|
||||
osx_image: xcode10.3
|
||||
|
||||
_android: &_android
|
||||
language: android
|
||||
@@ -57,6 +57,8 @@ matrix:
|
||||
<<: *_ios
|
||||
- env: PLATFORM=ios-12.0
|
||||
<<: *_ios
|
||||
- env: PLATFORM=ios-12.2
|
||||
<<: *_ios
|
||||
|
||||
- env: PLATFORM=android-5.1
|
||||
<<: *_android
|
||||
|
||||
@@ -68,14 +68,6 @@ simply hook `window.open` during initialization. For example:
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
}
|
||||
|
||||
### Preferences
|
||||
|
||||
#### <b>config.xml</b>
|
||||
- <b>InAppBrowserStatusBarStyle [iOS only]</b>: (string, options 'lightcontent' or 'default'. Defaults to 'default') set text color style for iOS.
|
||||
```
|
||||
<preference name="InAppBrowserStatusBarStyle" value="lightcontent" />
|
||||
```
|
||||
|
||||
## cordova.InAppBrowser.open
|
||||
|
||||
Opens a URL in a new `InAppBrowser` instance, the current browser
|
||||
@@ -176,16 +168,6 @@ At the moment the only supported target in OSX is `_system`.
|
||||
|
||||
`_blank` and `_self` targets are not yet implemented and are ignored silently. Pull requests and patches to get these to work are greatly appreciated.
|
||||
|
||||
### iOS Quirks
|
||||
|
||||
Since the introduction of iPadOS 13, iPads try to adapt their content mode / user agent for the optimal browsing experience. This may result in iPads having their user agent set to Macintosh, making it hard to detect them as mobile devices using user agent string sniffing. You can change this with the `PreferredContentMode` preference in `config.xml`.
|
||||
|
||||
```xml
|
||||
<preference name="PreferredContentMode" value="mobile" />
|
||||
```
|
||||
|
||||
The example above forces the user agent to contain `iPad`. The other option is to use the value `desktop` to turn the user agent to `Macintosh`.
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
- Plugin is implemented via iframe,
|
||||
|
||||
@@ -20,46 +20,6 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 4.1.0 (Nov 17, 2020)
|
||||
* [GH-792](https://github.com/apache/cordova-plugin-inappbrowser/pull/792) fix(android): Add mitigation strategy for CVE-2020-6506
|
||||
* [GH-817](https://github.com/apache/cordova-plugin-inappbrowser/pull/817) Updated typings
|
||||
* [GH-803](https://github.com/apache/cordova-plugin-inappbrowser/pull/803) fix(android): allow compilation in old `cordova-android` versions
|
||||
* [GH-688](https://github.com/apache/cordova-plugin-inappbrowser/pull/688) (ios): allow to set "preferredContentMode"
|
||||
* [GH-768](https://github.com/apache/cordova-plugin-inappbrowser/pull/768) ci(travis): update osx xcode image
|
||||
* add documentation for `InAppBrowser`StatusBarStyle preference
|
||||
* undo whitespace changes due to editor preferrences
|
||||
* [GH-728](https://github.com/apache/cordova-plugin-inappbrowser/pull/728) **iOS**: added `InAppBrowser`StatusBarStyle preference
|
||||
* [GH-767](https://github.com/apache/cordova-plugin-inappbrowser/pull/767) ci(travis): updates **Android** API level
|
||||
* (ios): Fix incorrect view height from the second open time
|
||||
* [GH-748](https://github.com/apache/cordova-plugin-inappbrowser/pull/748) chore: adds package-lock file
|
||||
* [GH-746](https://github.com/apache/cordova-plugin-inappbrowser/pull/746) chore(npm): use short notation in `package.json`
|
||||
* [GH-747](https://github.com/apache/cordova-plugin-inappbrowser/pull/747) refactor(eslint): use cordova-eslint /w fix
|
||||
* [GH-737](https://github.com/apache/cordova-plugin-inappbrowser/pull/737) fix(ios): exit event not fired on swipe down
|
||||
|
||||
### 4.0.0 (Jun 09, 2020)
|
||||
* [GH-715](https://github.com/apache/cordova-plugin-inappbrowser/pull/715) (ios): fix regression in 2706f34
|
||||
* [GH-685](https://github.com/apache/cordova-plugin-inappbrowser/pull/685) chore: update install engines
|
||||
* [GH-656](https://github.com/apache/cordova-plugin-inappbrowser/pull/656) (ios) Remove fake status bar with hardcoded height to fix issues in **iOS** devices with a notch
|
||||
* [GH-693](https://github.com/apache/cordova-plugin-inappbrowser/pull/693) fix(ios): Allow loading local html files
|
||||
* [GH-293](https://github.com/apache/cordova-plugin-inappbrowser/pull/293) **Android**: SSL errors handling in **Android**
|
||||
* [GH-672](https://github.com/apache/cordova-plugin-inappbrowser/pull/672) fix(ios): prevent statusbar rotation after closing `InAppBrowser`
|
||||
* chore(asf): update git notification settings
|
||||
* [GH-669](https://github.com/apache/cordova-plugin-inappbrowser/pull/669) Allow App using `InAppBrowser` to be hosted in a cross-origin iframe
|
||||
* [GH-600](https://github.com/apache/cordova-plugin-inappbrowser/pull/600) (all platforms): remove "window.open" overwrite
|
||||
* [GH-670](https://github.com/apache/cordova-plugin-inappbrowser/pull/670) chore: bump version to 4.0.0-dev
|
||||
* Update CONTRIBUTING.md
|
||||
* [GH-662](https://github.com/apache/cordova-plugin-inappbrowser/pull/662) docs: replaces outdated transition and presentation style links
|
||||
* [GH-666](https://github.com/apache/cordova-plugin-inappbrowser/pull/666) chore: remove deprecated orientation methods
|
||||
* [GH-515](https://github.com/apache/cordova-plugin-inappbrowser/pull/515) Fix incorrect TypeScript typings
|
||||
* [GH-654](https://github.com/apache/cordova-plugin-inappbrowser/pull/654) add check for openInSystem postNotification
|
||||
* [GH-659](https://github.com/apache/cordova-plugin-inappbrowser/pull/659) ci: updates Node.js versions
|
||||
* [GH-658](https://github.com/apache/cordova-plugin-inappbrowser/pull/658) chore(npm): improve ignore list
|
||||
* [GH-442](https://github.com/apache/cordova-plugin-inappbrowser/pull/442) fix(android): Reset lefttoright if not set
|
||||
* [GH-648](https://github.com/apache/cordova-plugin-inappbrowser/pull/648) (android) Correcting the documentation regarding lefttoright opt…
|
||||
* [GH-634](https://github.com/apache/cordova-plugin-inappbrowser/pull/634) (android) Added option to turn on/off fullscreen mode in **Android**
|
||||
* [GH-616](https://github.com/apache/cordova-plugin-inappbrowser/pull/616) (android) `InAppBrowser`: java.lang.IllegalArgumentException
|
||||
* [GH-635](https://github.com/apache/cordova-plugin-inappbrowser/pull/635) breaking(ios): remove UIWebView
|
||||
|
||||
### 3.2.0 (Jan 04, 2020)
|
||||
* [GH-503](https://github.com/apache/cordova-plugin-inappbrowser/pull/503) Defensive code to prevent NULL reference exceptions for async
|
||||
* [GH-584](https://github.com/apache/cordova-plugin-inappbrowser/pull/584) Add compile-time decision for disabling UIWebView
|
||||
|
||||
Generated
-1724
File diff suppressed because it is too large
Load Diff
+17
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "4.1.0",
|
||||
"version": "4.0.0-dev",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
@@ -13,8 +13,13 @@
|
||||
"windows"
|
||||
]
|
||||
},
|
||||
"repository": "github:apache/cordova-plugin-inappbrowser",
|
||||
"bugs": "https://github.com/apache/cordova-plugin-inappbrowser/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"in",
|
||||
@@ -29,8 +34,8 @@
|
||||
"cordova-windows"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run lint",
|
||||
"lint": "eslint ."
|
||||
"test": "npm run eslint",
|
||||
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
|
||||
},
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
@@ -38,10 +43,6 @@
|
||||
"cordova": ">=3.1.0"
|
||||
},
|
||||
"4.0.0": {
|
||||
"cordova": ">=3.1.0",
|
||||
"cordova-ios": ">=4.0.0"
|
||||
},
|
||||
"5.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
@@ -49,6 +50,12 @@
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@cordova/eslint-config": "^3.0.0"
|
||||
"eslint": "^4.0.0",
|
||||
"eslint-config-semistandard": "^11.0.0",
|
||||
"eslint-config-standard": "^10.2.1",
|
||||
"eslint-plugin-import": "^2.3.0",
|
||||
"eslint-plugin-node": "^5.0.0",
|
||||
"eslint-plugin-promise": "^3.5.0",
|
||||
"eslint-plugin-standard": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="4.1.0">
|
||||
version="4.0.0-dev">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
|
||||
<engine name="cordova-ios" version=">=4.0.0" />
|
||||
</engines>
|
||||
|
||||
<!-- android -->
|
||||
|
||||
@@ -269,8 +269,12 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void run() {
|
||||
currentClient.waitForBeforeload = false;
|
||||
inAppWebView.setWebViewClient(currentClient);
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
|
||||
currentClient.waitForBeforeload = false;
|
||||
inAppWebView.setWebViewClient(currentClient);
|
||||
} else {
|
||||
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
|
||||
}
|
||||
inAppWebView.loadUrl(url);
|
||||
}
|
||||
});
|
||||
@@ -410,7 +414,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
// This action will have the side-effect of blurring the currently focused element
|
||||
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
|
||||
} else {
|
||||
@@ -1002,7 +1006,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= 17) {
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
|
||||
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
|
||||
}
|
||||
@@ -1034,7 +1038,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
}
|
||||
|
||||
// Enable Thirdparty Cookies on >=Android 5.0 device
|
||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
|
||||
}
|
||||
|
||||
@@ -1042,9 +1046,6 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
inAppWebView.setId(Integer.valueOf(6));
|
||||
inAppWebView.getSettings().setLoadWithOverviewMode(true);
|
||||
inAppWebView.getSettings().setUseWideViewPort(useWideViewPort);
|
||||
// Multiple Windows set to true to mitigate Chromium security bug.
|
||||
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=1083819
|
||||
inAppWebView.getSettings().setSupportMultipleWindows(true);
|
||||
inAppWebView.requestFocus();
|
||||
inAppWebView.requestFocusFromTouch();
|
||||
|
||||
@@ -1128,7 +1129,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
*/
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
// For Android >= 5.0
|
||||
if(Build.VERSION.SDK_INT >= 21) {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
|
||||
// If RequestCode or Callback is Invalid
|
||||
if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
|
||||
@@ -1201,7 +1202,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
* @param webView
|
||||
* @param request
|
||||
*/
|
||||
@TargetApi(24)
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) {
|
||||
return shouldOverrideUrlLoading(request.getUrl().toString(), request.getMethod());
|
||||
@@ -1373,7 +1374,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
* @param webView
|
||||
* @param request
|
||||
*/
|
||||
@TargetApi(21)
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
|
||||
@@ -1424,12 +1425,12 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
super.onPageFinished(view, url);
|
||||
|
||||
// Set the namespace for postMessage()
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
|
||||
}
|
||||
|
||||
// CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
|
||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().flush();
|
||||
} else {
|
||||
CookieSyncManager.getInstance().sync();
|
||||
|
||||
@@ -24,12 +24,8 @@ import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.os.Message;
|
||||
import android.webkit.JsPromptResult;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebStorage;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
@@ -139,45 +135,4 @@ public class InAppChromeClient extends WebChromeClient {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The InAppWebBrowser WebView is configured to MultipleWindow mode to mitigate a security
|
||||
* bug found in Chromium prior to version 83.0.4103.106.
|
||||
* See https://bugs.chromium.org/p/chromium/issues/detail?id=1083819
|
||||
*
|
||||
* Valid Urls set to open in new window will be routed back to load in the original WebView.
|
||||
*
|
||||
* @param view
|
||||
* @param isDialog
|
||||
* @param isUserGesture
|
||||
* @param resultMsg
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
|
||||
WebView inAppWebView = view;
|
||||
final WebViewClient webViewClient =
|
||||
new WebViewClient() {
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||
inAppWebView.loadUrl(request.getUrl().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
inAppWebView.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
final WebView newWebView = new WebView(view.getContext());
|
||||
newWebView.setWebViewClient(webViewClient);
|
||||
|
||||
final WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
|
||||
transport.setWebView(newWebView);
|
||||
resultMsg.sendToTarget();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,37 +17,43 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
|
||||
var browserWrap,
|
||||
popup,
|
||||
navigationButtonsDiv,
|
||||
navigationButtonsDivInner,
|
||||
backButton,
|
||||
forwardButton,
|
||||
closeButton;
|
||||
|
||||
function attachNavigationEvents (element, callback) {
|
||||
var onError = function () {
|
||||
try {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loaderror', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
};
|
||||
|
||||
element.addEventListener('pageshow', function () {
|
||||
try {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstart', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('load', function () {
|
||||
try {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstop', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
@@ -147,9 +153,7 @@ var IAB = {
|
||||
|
||||
backButton.innerHTML = '←';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
}
|
||||
if (popup.canGoBack) { popup.goBack(); }
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('button');
|
||||
@@ -160,9 +164,7 @@ var IAB = {
|
||||
|
||||
forwardButton.innerHTML = '→';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) {
|
||||
popup.goForward();
|
||||
}
|
||||
if (popup.canGoForward) { popup.goForward(); }
|
||||
});
|
||||
|
||||
closeButton = document.createElement('button');
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#import "CDVInAppBrowserNavigationController.h"
|
||||
|
||||
#define STATUSBAR_HEIGHT 20.0
|
||||
|
||||
@implementation CDVInAppBrowserNavigationController : UINavigationController
|
||||
|
||||
- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
|
||||
@@ -28,6 +30,16 @@
|
||||
}
|
||||
|
||||
- (void) viewDidLoad {
|
||||
|
||||
CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
|
||||
statusBarFrame.size.height = STATUSBAR_HEIGHT;
|
||||
// simplified from: http://stackoverflow.com/a/25669695/219684
|
||||
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:statusBarFrame];
|
||||
bgToolbar.barStyle = UIBarStyleDefault;
|
||||
[bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
|
||||
[self.view addSubview:bgToolbar];
|
||||
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler,UIAdaptivePresentationControllerDelegate>{
|
||||
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler>{
|
||||
@private
|
||||
CDVInAppBrowserOptions *_browserOptions;
|
||||
NSDictionary *_settings;
|
||||
|
||||
+22
-62
@@ -35,6 +35,7 @@
|
||||
#define IAB_BRIDGE_NAME @"cordova_iab"
|
||||
|
||||
#define TOOLBAR_HEIGHT 44.0
|
||||
#define STATUSBAR_HEIGHT 20.0
|
||||
#define LOCATIONBAR_HEIGHT 21.0
|
||||
#define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT))
|
||||
|
||||
@@ -290,7 +291,6 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
nav.orientationDelegate = self.inAppBrowserViewController;
|
||||
nav.navigationBarHidden = YES;
|
||||
nav.modalPresentationStyle = self.inAppBrowserViewController.modalPresentationStyle;
|
||||
nav.presentationController.delegate = self.inAppBrowserViewController;
|
||||
|
||||
__weak CDVWKInAppBrowser* weakSelf = self;
|
||||
|
||||
@@ -307,6 +307,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
|
||||
}
|
||||
UIViewController *tmpController = [[UIViewController alloc] init];
|
||||
|
||||
[strongSelf->tmpWindow setRootViewController:tmpController];
|
||||
[strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal];
|
||||
|
||||
@@ -697,7 +698,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
|
||||
@synthesize currentURL;
|
||||
|
||||
CGFloat lastReducedStatusBarHeight = 0.0;
|
||||
BOOL viewRenderedAtLeastOnce = FALSE;
|
||||
BOOL isExiting = FALSE;
|
||||
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary *)settings
|
||||
@@ -757,15 +758,6 @@ BOOL isExiting = FALSE;
|
||||
configuration.mediaPlaybackRequiresUserAction = _browserOptions.mediaplaybackrequiresuseraction;
|
||||
}
|
||||
|
||||
if (@available(iOS 13.0, *)) {
|
||||
NSString *contentMode = [self settingForKey:@"PreferredContentMode"];
|
||||
if ([contentMode isEqual: @"mobile"]) {
|
||||
configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile;
|
||||
} else if ([contentMode isEqual: @"desktop"]) {
|
||||
configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeDesktop;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.webView = [[WKWebView alloc] initWithFrame:webViewBounds configuration:configuration];
|
||||
@@ -904,7 +896,7 @@ BOOL isExiting = FALSE;
|
||||
[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
|
||||
}
|
||||
|
||||
self.view.backgroundColor = [UIColor clearColor];
|
||||
self.view.backgroundColor = [UIColor grayColor];
|
||||
[self.view addSubview:self.toolbar];
|
||||
[self.view addSubview:self.addressLabel];
|
||||
[self.view addSubview:self.spinner];
|
||||
@@ -1050,6 +1042,7 @@ BOOL isExiting = FALSE;
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
viewRenderedAtLeastOnce = FALSE;
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
@@ -1064,12 +1057,7 @@ BOOL isExiting = FALSE;
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
NSString* statusBarStylePreference = [self settingForKey:@"InAppBrowserStatusBarStyle"];
|
||||
if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"lightcontent"]) {
|
||||
return UIStatusBarStyleLightContent;
|
||||
} else {
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
@@ -1085,7 +1073,6 @@ BOOL isExiting = FALSE;
|
||||
// Run later to avoid the "took a long time" log message.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
isExiting = TRUE;
|
||||
lastReducedStatusBarHeight = 0.0;
|
||||
if ([weakSelf respondsToSelector:@selector(presentingViewController)]) {
|
||||
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
} else {
|
||||
@@ -1096,12 +1083,8 @@ BOOL isExiting = FALSE;
|
||||
|
||||
- (void)navigateTo:(NSURL*)url
|
||||
{
|
||||
if ([url.scheme isEqualToString:@"file"]) {
|
||||
[self.webView loadFileURL:url allowingReadAccessToURL:url];
|
||||
} else {
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
|
||||
- (void)goBack:(id)sender
|
||||
@@ -1116,6 +1099,14 @@ BOOL isExiting = FALSE;
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
if (IsAtLeastiOSVersion(@"7.0") && !viewRenderedAtLeastOnce) {
|
||||
viewRenderedAtLeastOnce = TRUE;
|
||||
CGRect viewBounds = [self.webView bounds];
|
||||
viewBounds.origin.y = STATUSBAR_HEIGHT;
|
||||
viewBounds.size.height = viewBounds.size.height - STATUSBAR_HEIGHT;
|
||||
self.webView.frame = viewBounds;
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
|
||||
}
|
||||
[self rePositionViews];
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
@@ -1127,28 +1118,16 @@ BOOL isExiting = FALSE;
|
||||
// change that value.
|
||||
//
|
||||
- (float) getStatusBarOffset {
|
||||
return (float) IsAtLeastiOSVersion(@"7.0") ? [[UIApplication sharedApplication] statusBarFrame].size.height : 0.0;
|
||||
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
|
||||
float statusBarOffset = IsAtLeastiOSVersion(@"7.0") ? MIN(statusBarFrame.size.width, statusBarFrame.size.height) : 0.0;
|
||||
return statusBarOffset;
|
||||
}
|
||||
|
||||
- (void) rePositionViews {
|
||||
CGRect viewBounds = [self.webView bounds];
|
||||
CGFloat statusBarHeight = [self getStatusBarOffset];
|
||||
|
||||
// orientation portrait or portraitUpsideDown: status bar is on the top and web view is to be aligned to the bottom of the status bar
|
||||
// orientation landscapeLeft or landscapeRight: status bar height is 0 in but lets account for it in case things ever change in the future
|
||||
viewBounds.origin.y = statusBarHeight;
|
||||
|
||||
// account for web view height portion that may have been reduced by a previous call to this method
|
||||
viewBounds.size.height = viewBounds.size.height - statusBarHeight + lastReducedStatusBarHeight;
|
||||
lastReducedStatusBarHeight = statusBarHeight;
|
||||
|
||||
if ((_browserOptions.toolbar) && ([_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop])) {
|
||||
// if we have to display the toolbar on top of the web view, we need to account for its height
|
||||
viewBounds.origin.y += TOOLBAR_HEIGHT;
|
||||
self.toolbar.frame = CGRectMake(self.toolbar.frame.origin.x, statusBarHeight, self.toolbar.frame.size.width, self.toolbar.frame.size.height);
|
||||
if ([_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop]) {
|
||||
[self.webView setFrame:CGRectMake(self.webView.frame.origin.x, TOOLBAR_HEIGHT, self.webView.frame.size.width, self.webView.frame.size.height)];
|
||||
[self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, [self getStatusBarOffset], self.toolbar.frame.size.width, self.toolbar.frame.size.height)];
|
||||
}
|
||||
|
||||
self.webView.frame = viewBounds;
|
||||
}
|
||||
|
||||
// Helper function to convert hex color string to UIColor
|
||||
@@ -1259,23 +1238,4 @@ BOOL isExiting = FALSE;
|
||||
return 1 << UIInterfaceOrientationPortrait;
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
||||
{
|
||||
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
|
||||
{
|
||||
[self rePositionViews];
|
||||
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
|
||||
{
|
||||
|
||||
}];
|
||||
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
}
|
||||
|
||||
#pragma mark UIAdaptivePresentationControllerDelegate
|
||||
|
||||
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController {
|
||||
isExiting = TRUE;
|
||||
}
|
||||
|
||||
@end //CDVWKInAppBrowserViewController
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
/* eslint-disable standard/no-callback-literal */
|
||||
/* global Windows, setImmediate */
|
||||
/* jslint sloppy:true */
|
||||
/* global Windows:true, setImmediate */
|
||||
/* eslint standard/no-callback-literal : 0 */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
@@ -43,32 +44,21 @@ var isWebViewAvailable = cordova.platformId === 'windows';
|
||||
function attachNavigationEvents (element, callback) {
|
||||
if (isWebViewAvailable) {
|
||||
element.addEventListener('MSWebViewNavigationStarting', function (e) {
|
||||
callback({ type: 'loadstart', url: e.uri }, { keepCallback: true });
|
||||
callback({ type: 'loadstart', url: e.uri }, {keepCallback: true});
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewNavigationCompleted', function (e) {
|
||||
if (e.isSuccess) {
|
||||
callback({ type: 'loadstop', url: e.uri }, { keepCallback: true });
|
||||
} else {
|
||||
callback(
|
||||
{
|
||||
type: 'loaderror',
|
||||
url: e.uri,
|
||||
code: e.webErrorStatus,
|
||||
message: 'Navigation failed with error code ' + e.webErrorStatus
|
||||
},
|
||||
{ keepCallback: true }
|
||||
);
|
||||
callback({ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true });
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewUnviewableContentIdentified', function (e) {
|
||||
// WebView found the content to be not HTML.
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx
|
||||
callback(
|
||||
{ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus },
|
||||
{ keepCallback: true }
|
||||
);
|
||||
callback({ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewContentLoading', function (e) {
|
||||
@@ -88,15 +78,15 @@ function attachNavigationEvents (element, callback) {
|
||||
});
|
||||
} else {
|
||||
var onError = function () {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location }, { keepCallback: true });
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location }, {keepCallback: true});
|
||||
};
|
||||
|
||||
element.addEventListener('unload', function () {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location }, { keepCallback: true });
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location }, {keepCallback: true});
|
||||
});
|
||||
|
||||
element.addEventListener('load', function () {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location }, { keepCallback: true });
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location }, {keepCallback: true});
|
||||
});
|
||||
|
||||
element.addEventListener('error', onError);
|
||||
@@ -185,8 +175,7 @@ var IAB = {
|
||||
}
|
||||
|
||||
popup = document.createElement(isWebViewAvailable ? 'x-ms-webview' : 'iframe');
|
||||
if (popup instanceof HTMLIFrameElement) {
|
||||
// eslint-disable-line no-undef
|
||||
if (popup instanceof HTMLIFrameElement) { // eslint-disable-line no-undef
|
||||
// For iframe we need to override bacground color of parent element here
|
||||
// otherwise pages without background color set will have transparent background
|
||||
popup.style.backgroundColor = 'white';
|
||||
@@ -251,18 +240,14 @@ var IAB = {
|
||||
backButton.innerText = 'back';
|
||||
backButton.className = 'app-bar-action action-back';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
}
|
||||
if (popup.canGoBack) { popup.goBack(); }
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('div');
|
||||
forwardButton.innerText = 'forward';
|
||||
forwardButton.className = 'app-bar-action action-forward';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) {
|
||||
popup.goForward();
|
||||
}
|
||||
if (popup.canGoForward) { popup.goForward(); }
|
||||
});
|
||||
|
||||
closeButton = document.createElement('div');
|
||||
@@ -307,11 +292,11 @@ var IAB = {
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
// return null if event target is unavailable by some reason
|
||||
var result = e && e.target ? [e.target.result] : [null];
|
||||
var result = (e && e.target) ? [e.target.result] : [null];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
}
|
||||
});
|
||||
@@ -338,7 +323,7 @@ var IAB = {
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
});
|
||||
});
|
||||
@@ -367,18 +352,13 @@ var IAB = {
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
|
||||
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri)
|
||||
.then(function (file) {
|
||||
return Windows.Storage.FileIO.readTextAsync(file);
|
||||
})
|
||||
.done(
|
||||
function (code) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
},
|
||||
function () {
|
||||
// no-op, just catch an error
|
||||
}
|
||||
);
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) {
|
||||
return Windows.Storage.FileIO.readTextAsync(file);
|
||||
}).done(function (code) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}, function () {
|
||||
// no-op, just catch an error
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -387,10 +367,8 @@ var IAB = {
|
||||
function injectCSS (webView, cssCode, callback) {
|
||||
// This will automatically escape all thing that we need (quotes, slashes, etc.)
|
||||
var escapedCode = JSON.stringify(cssCode);
|
||||
var evalWrapper = "(function(d){var c=d.createElement('style');c.innerHTML=%s;d.head.appendChild(c);})(document)".replace(
|
||||
'%s',
|
||||
escapedCode
|
||||
);
|
||||
var evalWrapper = '(function(d){var c=d.createElement(\'style\');c.innerHTML=%s;d.head.appendChild(c);})(document)'
|
||||
.replace('%s', escapedCode);
|
||||
|
||||
var op = webView.invokeScriptAsync('eval', evalWrapper);
|
||||
op.oncomplete = function () {
|
||||
@@ -398,7 +376,7 @@ function injectCSS (webView, cssCode, callback) {
|
||||
callback([]);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser-tests",
|
||||
"version": "4.1.0",
|
||||
"version": "4.0.0-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser-tests",
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="4.1.0">
|
||||
version="4.0.0-dev">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
*/
|
||||
var d = document.getElementById('header');
|
||||
d.innerHTML = 'Script file successfully injected';
|
||||
|
||||
+244
-523
@@ -17,7 +17,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
/* global MSApp */
|
||||
|
||||
@@ -38,6 +38,7 @@ exports.defineAutoTests = function () {
|
||||
platformOpts = platformOpts || '';
|
||||
|
||||
describe('cordova.InAppBrowser', function () {
|
||||
|
||||
it('inappbrowser.spec.1 should exist', function () {
|
||||
expect(cordova.InAppBrowser).toBeDefined();
|
||||
});
|
||||
@@ -49,6 +50,7 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
describe('open method', function () {
|
||||
|
||||
if (cordova.platformId === 'osx') {
|
||||
pending('Open method not fully supported on OSX.');
|
||||
return;
|
||||
@@ -60,7 +62,7 @@ exports.defineAutoTests = function () {
|
||||
var badUrl = 'http://bad-uri/';
|
||||
|
||||
beforeEach(function () {
|
||||
// increase timeout to ensure test url could be loaded within test time
|
||||
// increase timeout to ensure test url could be loaded within test time
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
|
||||
@@ -68,7 +70,7 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
// restore original timeout
|
||||
// restore original timeout
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
|
||||
if (iabInstance !== null && iabInstance.close) {
|
||||
@@ -120,8 +122,8 @@ exports.defineAutoTests = function () {
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
verifyEvent(evt, 'loadstop');
|
||||
if (!isBrowser) {
|
||||
// according to documentation, "loadstart" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
// according to documentation, "loadstart" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
}
|
||||
done();
|
||||
@@ -142,9 +144,9 @@ exports.defineAutoTests = function () {
|
||||
|
||||
it('inappbrowser.spec.6 should support loaderror event', function (done) {
|
||||
if (isBrowser) {
|
||||
// according to documentation, "loaderror" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
pending("Browser platform doesn't support loaderror event");
|
||||
// according to documentation, "loaderror" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
pending('Browser platform doesn\'t support loaderror event');
|
||||
}
|
||||
iabInstance = cordova.InAppBrowser.open(badUrl, '_blank', platformOpts);
|
||||
iabInstance.addEventListener('loaderror', function (evt) {
|
||||
@@ -155,7 +157,7 @@ exports.defineAutoTests = function () {
|
||||
|
||||
it('inappbrowser.spec.7 should support message event', function (done) {
|
||||
if (!isAndroid && !isIos) {
|
||||
return pending(cordova.platformId + " platform doesn't support message event");
|
||||
return pending(cordova.platformId + ' platform doesn\'t support message event');
|
||||
}
|
||||
var messageKey = 'my_message';
|
||||
var messageValue = 'is_this';
|
||||
@@ -170,17 +172,13 @@ exports.defineAutoTests = function () {
|
||||
done();
|
||||
});
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
var code =
|
||||
'(function(){\n' +
|
||||
' var message = {' +
|
||||
messageKey +
|
||||
': "' +
|
||||
messageValue +
|
||||
'"};\n' +
|
||||
var code = '(function(){\n' +
|
||||
' var message = {' + messageKey + ': "' + messageValue + '"};\n' +
|
||||
' webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(message));\n' +
|
||||
'})()';
|
||||
iabInstance.executeScript({ code: code });
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -188,6 +186,7 @@ exports.defineAutoTests = function () {
|
||||
};
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
var platformOpts = '';
|
||||
var platform_info = '';
|
||||
|
||||
@@ -201,10 +200,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
var wasReset = false;
|
||||
function reset () {
|
||||
counts = {
|
||||
loaderror: 0,
|
||||
loadstart: 0,
|
||||
loadstop: 0,
|
||||
exit: 0
|
||||
'loaderror': 0,
|
||||
'loadstart': 0,
|
||||
'loadstop': 0,
|
||||
'exit': 0
|
||||
};
|
||||
lastLoadStartURL = '';
|
||||
}
|
||||
@@ -244,20 +243,15 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
// Verify the right number of loadstart events were fired.
|
||||
if (e.type === 'loadstop' || e.type === 'loaderror') {
|
||||
if (e.url !== lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + " event.url != loadstart's event.url"); // eslint-disable-line no-undef
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url'); // eslint-disable-line no-undef
|
||||
}
|
||||
if (numExpectedRedirects === 0 && counts.loadstart !== 1) {
|
||||
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
||||
if (!(e.type === 'loaderror' && counts.loadstart === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); // eslint-disable-line no-undef
|
||||
}
|
||||
} else if (numExpectedRedirects > 0 && counts.loadstart < numExpectedRedirects + 1) {
|
||||
alert(
|
||||
'Unexpected: should have got at least ' +
|
||||
(numExpectedRedirects + 1) +
|
||||
' loadstart events, but got ' +
|
||||
counts.loadstart
|
||||
); // eslint-disable-line no-undef
|
||||
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart); // eslint-disable-line no-undef
|
||||
}
|
||||
wasReset = true;
|
||||
numExpectedRedirects = 0;
|
||||
@@ -279,7 +273,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
function doHookOpen (url, target, params, numExpectedRedirects) {
|
||||
var originalFunc = window.open;
|
||||
var wasClobbered = Object.prototype.hasOwnProperty.call(window, 'open');
|
||||
var wasClobbered = window.hasOwnProperty('open');
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
try {
|
||||
@@ -301,7 +295,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof results + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
};
|
||||
if (cssUrl) {
|
||||
@@ -310,7 +304,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.insertCSS({ code: '#style-update-literal { \ndisplay: block !important; \n}' }, useCallback && callback);
|
||||
iab.insertCSS({ code: '#style-update-literal { \ndisplay: block !important; \n}' },
|
||||
useCallback && callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -319,48 +314,37 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
if (jsUrl) {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.executeScript(
|
||||
{ file: jsUrl },
|
||||
useCallback &&
|
||||
function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof results + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
}
|
||||
);
|
||||
iab.executeScript({ file: jsUrl }, useCallback && function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
var code =
|
||||
'(function(){\n' +
|
||||
' var header = document.getElementById("header");\n' +
|
||||
' header.innerHTML = "Script literal successfully injected";\n' +
|
||||
' return "abc";\n' +
|
||||
'})()';
|
||||
iab.executeScript(
|
||||
{ code: code },
|
||||
useCallback &&
|
||||
function (results) {
|
||||
if (results && results.length === 1 && results[0] === 'abc') {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof results + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
}
|
||||
);
|
||||
var code = '(function(){\n' +
|
||||
' var header = document.getElementById("header");\n' +
|
||||
' header.innerHTML = "Script literal successfully injected";\n' +
|
||||
' return "abc";\n' +
|
||||
'})()';
|
||||
iab.executeScript({ code: code }, useCallback && function (results) {
|
||||
if (results && results.length === 1 && results[0] === 'abc') {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
var hiddenwnd = null;
|
||||
var loadlistener = function (event) {
|
||||
alert('background window loaded ');
|
||||
}; // eslint-disable-line no-undef
|
||||
var loadlistener = function (event) { alert('background window loaded '); }; // eslint-disable-line no-undef
|
||||
function openHidden (url, startHidden) {
|
||||
var shopt = startHidden ? 'hidden=yes' : '';
|
||||
var shopt = (startHidden) ? 'hidden=yes' : '';
|
||||
if (platformOpts) {
|
||||
shopt += (shopt ? ',' : '') + platformOpts;
|
||||
}
|
||||
@@ -384,8 +368,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
}
|
||||
|
||||
var info_div =
|
||||
'<h1>InAppBrowser</h1>' +
|
||||
var info_div = '<h1>InAppBrowser</h1>' +
|
||||
'<div id="info">' +
|
||||
'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
|
||||
'Make sure http://www.apple.com is not in the white list.</br>' +
|
||||
@@ -393,8 +376,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<h4>User-Agent: <span id="user-agent"> </span></hr>' +
|
||||
'</div>';
|
||||
|
||||
var local_tests =
|
||||
'<h1>Local URL</h1>' +
|
||||
var local_tests = '<h1>Local URL</h1>' +
|
||||
'<div id="openLocal"></div>' +
|
||||
'Expected result: opens successfully in CordovaWebView.' +
|
||||
'<p/> <div id="openLocalHook"></div>' +
|
||||
@@ -414,8 +396,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/><div id="openLocalRandomToolBarTopNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with no locationBar. On iOS the toolbar is at the top.';
|
||||
|
||||
var white_listed_tests =
|
||||
'<h1>White Listed URL</h1>' +
|
||||
var white_listed_tests = '<h1>White Listed URL</h1>' +
|
||||
'<div id="openWhiteListed"></div>' +
|
||||
'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
|
||||
'<p/> <div id="openWhiteListedHook"></div>' +
|
||||
@@ -431,8 +412,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openWhiteListedRandomNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to cordova.apache.org with no location bar.';
|
||||
|
||||
var non_white_listed_tests =
|
||||
'<h1>Non White Listed URL</h1>' +
|
||||
var non_white_listed_tests = '<h1>Non White Listed URL</h1>' +
|
||||
'<div id="openNonWhiteListed"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
||||
'<p/> <div id="openNonWhiteListedHook"></div>' +
|
||||
@@ -448,22 +428,19 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openNonWhiteListedRandomNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com without locationBar.';
|
||||
|
||||
var page_with_redirects_tests =
|
||||
'<h1>Page with redirect</h1>' +
|
||||
var page_with_redirects_tests = '<h1>Page with redirect</h1>' +
|
||||
'<div id="openRedirect301"></div>' +
|
||||
'Expected result: should 301 and open successfully in InAppBrowser to https://www.google.co.uk.' +
|
||||
'<p/> <div id="openRedirect302"></div>' +
|
||||
'Expected result: should 302 and open successfully in InAppBrowser to www.zhihu.com/answer/16714076.';
|
||||
|
||||
var pdf_url_tests =
|
||||
'<h1>PDF URL</h1>' +
|
||||
var pdf_url_tests = '<h1>PDF URL</h1>' +
|
||||
'<div id="openPDF"></div>' +
|
||||
'Expected result: InAppBrowser opens. PDF should render on iOS.' +
|
||||
'<p/> <div id="openPDFBlank"></div>' +
|
||||
'Expected result: InAppBrowser opens. PDF should render on iOS.';
|
||||
|
||||
var invalid_url_tests =
|
||||
'<h1>Invalid URL</h1>' +
|
||||
var invalid_url_tests = '<h1>Invalid URL</h1>' +
|
||||
'<div id="openInvalidScheme"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser.' +
|
||||
'<p/> <div id="openInvalidHost"></div>' +
|
||||
@@ -471,8 +448,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openInvalidMissing"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser (404).';
|
||||
|
||||
var css_js_injection_tests =
|
||||
'<h1>CSS / JS Injection</h1>' +
|
||||
var css_js_injection_tests = '<h1>CSS / JS Injection</h1>' +
|
||||
'<div id="openOriginalDocument"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser without text "Style updated from..."' +
|
||||
'<p/> <div id="openCSSInjection"></div>' +
|
||||
@@ -492,8 +468,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openScriptLiteralInjectionCallback"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with the text "Script literal successfully injected" and alert dialog with the text "Results verified".';
|
||||
|
||||
var open_hidden_tests =
|
||||
'<h1>Open Hidden </h1>' +
|
||||
var open_hidden_tests = '<h1>Open Hidden </h1>' +
|
||||
'<div id="openHidden"></div>' +
|
||||
'Expected result: no additional browser window. Alert appears with the text "background window loaded".' +
|
||||
'<p/> <div id="showHidden"></div>' +
|
||||
@@ -505,15 +480,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openVisibleAndHide"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk. Hide after 2 seconds';
|
||||
|
||||
var clearing_cache_tests =
|
||||
'<h1>Clearing Cache</h1>' +
|
||||
var clearing_cache_tests = '<h1>Clearing Cache</h1>' +
|
||||
'<div id="openClearCache"></div>' +
|
||||
'Expected result: ?' +
|
||||
'<p/> <div id="openClearSessionCache"></div>' +
|
||||
'Expected result: ?';
|
||||
|
||||
var video_tag_tests =
|
||||
'<h1>Video tag</h1>' +
|
||||
var video_tag_tests = '<h1>Video tag</h1>' +
|
||||
'<div id="openRemoteVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserNoVideo"></div>' +
|
||||
@@ -521,15 +494,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
||||
|
||||
var local_with_anchor_tag_tests =
|
||||
'<h1>Local with anchor tag</h1>' +
|
||||
var local_with_anchor_tag_tests = '<h1>Local with anchor tag</h1>' +
|
||||
'<div id="openAnchor1"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the top as normal.' +
|
||||
'<p/> <div id="openAnchor2"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.';
|
||||
|
||||
var hardwareback_tests =
|
||||
'<h1>HardwareBack</h1>' +
|
||||
var hardwareback_tests = '<h1>HardwareBack</h1>' +
|
||||
'<p/> <div id="openHardwareBackDefault"></div>' +
|
||||
'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' +
|
||||
'<p/> <div id="openHardwareBackYes"></div>' +
|
||||
@@ -543,38 +514,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
|
||||
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
|
||||
MSApp.execUnsafeLocalFunction(function () {
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
contentEl.innerHTML = info_div + platform_info + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
|
||||
css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests;
|
||||
});
|
||||
} else {
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
contentEl.innerHTML = info_div + platform_info + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
|
||||
css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests;
|
||||
}
|
||||
|
||||
document.getElementById('user-agent').textContent = navigator.userAgent;
|
||||
@@ -589,430 +534,206 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
var videohtml = basePath + 'video.html';
|
||||
|
||||
// Local
|
||||
createActionButton(
|
||||
'target=Default',
|
||||
function () {
|
||||
doOpen(localhtml);
|
||||
},
|
||||
'openLocal'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Default (window.open)',
|
||||
function () {
|
||||
doHookOpen(localhtml);
|
||||
},
|
||||
'openLocalHook'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_self',
|
||||
function () {
|
||||
doOpen(localhtml, '_self');
|
||||
},
|
||||
'openLocalSelf'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_system',
|
||||
function () {
|
||||
doOpen(localhtml, '_system');
|
||||
},
|
||||
'openLocalSystem'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_blank',
|
||||
function () {
|
||||
doOpen(localhtml, '_blank');
|
||||
},
|
||||
'openLocalBlank'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random, location=no, disallowoverscroll=yes',
|
||||
function () {
|
||||
doOpen(localhtml, 'random_string', 'location=no, disallowoverscroll=yes');
|
||||
},
|
||||
'openLocalRandomNoLocation'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random, toolbarposition=bottom',
|
||||
function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=bottom');
|
||||
},
|
||||
'openLocalRandomToolBarBottom'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random, toolbarposition=top',
|
||||
function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top');
|
||||
},
|
||||
'openLocalRandomToolBarTop'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random, toolbarposition=top, location=no',
|
||||
function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top,location=no');
|
||||
},
|
||||
'openLocalRandomToolBarTopNoLocation'
|
||||
);
|
||||
createActionButton('target=Default', function () {
|
||||
doOpen(localhtml);
|
||||
}, 'openLocal');
|
||||
createActionButton('target=Default (window.open)', function () {
|
||||
doHookOpen(localhtml);
|
||||
}, 'openLocalHook');
|
||||
createActionButton('target=_self', function () {
|
||||
doOpen(localhtml, '_self');
|
||||
}, 'openLocalSelf');
|
||||
createActionButton('target=_system', function () {
|
||||
doOpen(localhtml, '_system');
|
||||
}, 'openLocalSystem');
|
||||
createActionButton('target=_blank', function () {
|
||||
doOpen(localhtml, '_blank');
|
||||
}, 'openLocalBlank');
|
||||
createActionButton('target=Random, location=no, disallowoverscroll=yes', function () {
|
||||
doOpen(localhtml, 'random_string', 'location=no, disallowoverscroll=yes');
|
||||
}, 'openLocalRandomNoLocation');
|
||||
createActionButton('target=Random, toolbarposition=bottom', function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=bottom');
|
||||
}, 'openLocalRandomToolBarBottom');
|
||||
createActionButton('target=Random, toolbarposition=top', function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top');
|
||||
}, 'openLocalRandomToolBarTop');
|
||||
createActionButton('target=Random, toolbarposition=top, location=no', function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top,location=no');
|
||||
}, 'openLocalRandomToolBarTopNoLocation');
|
||||
|
||||
// White Listed
|
||||
createActionButton(
|
||||
'* target=Default',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org');
|
||||
},
|
||||
'openWhiteListed'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=Default (window.open)',
|
||||
function () {
|
||||
doHookOpen('http://cordova.apache.org');
|
||||
},
|
||||
'openWhiteListedHook'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=_self',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', '_self');
|
||||
},
|
||||
'openWhiteListedSelf'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_system',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', '_system');
|
||||
},
|
||||
'openWhiteListedSystem'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_blank',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', '_blank');
|
||||
},
|
||||
'openWhiteListedBlank'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', 'random_string');
|
||||
},
|
||||
'openWhiteListedRandom'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=Random, no location bar',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', 'random_string', 'location=no');
|
||||
},
|
||||
'openWhiteListedRandomNoLocation'
|
||||
);
|
||||
createActionButton('* target=Default', function () {
|
||||
doOpen('http://cordova.apache.org');
|
||||
}, 'openWhiteListed');
|
||||
createActionButton('* target=Default (window.open)', function () {
|
||||
doHookOpen('http://cordova.apache.org');
|
||||
}, 'openWhiteListedHook');
|
||||
createActionButton('* target=_self', function () {
|
||||
doOpen('http://cordova.apache.org', '_self');
|
||||
}, 'openWhiteListedSelf');
|
||||
createActionButton('target=_system', function () {
|
||||
doOpen('http://cordova.apache.org', '_system');
|
||||
}, 'openWhiteListedSystem');
|
||||
createActionButton('target=_blank', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank');
|
||||
}, 'openWhiteListedBlank');
|
||||
createActionButton('target=Random', function () {
|
||||
doOpen('http://cordova.apache.org', 'random_string');
|
||||
}, 'openWhiteListedRandom');
|
||||
createActionButton('* target=Random, no location bar', function () {
|
||||
doOpen('http://cordova.apache.org', 'random_string', 'location=no');
|
||||
}, 'openWhiteListedRandomNoLocation');
|
||||
|
||||
// Non White Listed
|
||||
createActionButton(
|
||||
'target=Default',
|
||||
function () {
|
||||
doOpen('http://www.apple.com');
|
||||
},
|
||||
'openNonWhiteListed'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Default (window.open)',
|
||||
function () {
|
||||
doHookOpen('http://www.apple.com');
|
||||
},
|
||||
'openNonWhiteListedHook'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_self',
|
||||
function () {
|
||||
doOpen('http://www.apple.com', '_self');
|
||||
},
|
||||
'openNonWhiteListedSelf'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_system',
|
||||
function () {
|
||||
doOpen('http://www.apple.com', '_system');
|
||||
},
|
||||
'openNonWhiteListedSystem'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_blank',
|
||||
function () {
|
||||
doOpen('http://www.apple.com', '_blank');
|
||||
},
|
||||
'openNonWhiteListedBlank'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random',
|
||||
function () {
|
||||
doOpen('http://www.apple.com', 'random_string');
|
||||
},
|
||||
'openNonWhiteListedRandom'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=Random, no location bar',
|
||||
function () {
|
||||
doOpen('http://www.apple.com', 'random_string', 'location=no');
|
||||
},
|
||||
'openNonWhiteListedRandomNoLocation'
|
||||
);
|
||||
createActionButton('target=Default', function () {
|
||||
doOpen('http://www.apple.com');
|
||||
}, 'openNonWhiteListed');
|
||||
createActionButton('target=Default (window.open)', function () {
|
||||
doHookOpen('http://www.apple.com');
|
||||
}, 'openNonWhiteListedHook');
|
||||
createActionButton('target=_self', function () {
|
||||
doOpen('http://www.apple.com', '_self');
|
||||
}, 'openNonWhiteListedSelf');
|
||||
createActionButton('target=_system', function () {
|
||||
doOpen('http://www.apple.com', '_system');
|
||||
}, 'openNonWhiteListedSystem');
|
||||
createActionButton('target=_blank', function () {
|
||||
doOpen('http://www.apple.com', '_blank');
|
||||
}, 'openNonWhiteListedBlank');
|
||||
createActionButton('target=Random', function () {
|
||||
doOpen('http://www.apple.com', 'random_string');
|
||||
}, 'openNonWhiteListedRandom');
|
||||
createActionButton('* target=Random, no location bar', function () {
|
||||
doOpen('http://www.apple.com', 'random_string', 'location=no');
|
||||
}, 'openNonWhiteListedRandomNoLocation');
|
||||
|
||||
// Page with redirect
|
||||
createActionButton(
|
||||
'http://google.co.uk',
|
||||
function () {
|
||||
doOpen('http://google.co.uk', 'random_string', '', 1);
|
||||
},
|
||||
'openRedirect301'
|
||||
);
|
||||
createActionButton(
|
||||
'http://goo.gl/pUFqg',
|
||||
function () {
|
||||
doOpen('http://goo.gl/pUFqg', 'random_string', '', 2);
|
||||
},
|
||||
'openRedirect302'
|
||||
);
|
||||
createActionButton('http://google.co.uk', function () {
|
||||
doOpen('http://google.co.uk', 'random_string', '', 1);
|
||||
}, 'openRedirect301');
|
||||
createActionButton('http://goo.gl/pUFqg', function () {
|
||||
doOpen('http://goo.gl/pUFqg', 'random_string', '', 2);
|
||||
}, 'openRedirect302');
|
||||
|
||||
// PDF URL
|
||||
createActionButton(
|
||||
'Remote URL',
|
||||
function () {
|
||||
doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf');
|
||||
},
|
||||
'openPDF'
|
||||
);
|
||||
createActionButton(
|
||||
'Local URL',
|
||||
function () {
|
||||
doOpen(localpdf, '_blank');
|
||||
},
|
||||
'openPDFBlank'
|
||||
);
|
||||
createActionButton('Remote URL', function () {
|
||||
doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf');
|
||||
}, 'openPDF');
|
||||
createActionButton('Local URL', function () {
|
||||
doOpen(localpdf, '_blank');
|
||||
}, 'openPDFBlank');
|
||||
|
||||
// Invalid URL
|
||||
createActionButton(
|
||||
'Invalid Scheme',
|
||||
function () {
|
||||
doOpen('x-ttp://www.invalid.com/', '_blank');
|
||||
},
|
||||
'openInvalidScheme'
|
||||
);
|
||||
createActionButton(
|
||||
'Invalid Host',
|
||||
function () {
|
||||
doOpen('http://www.inv;alid.com/', '_blank');
|
||||
},
|
||||
'openInvalidHost'
|
||||
);
|
||||
createActionButton(
|
||||
'Missing Local File',
|
||||
function () {
|
||||
doOpen('nonexistent.html', '_blank');
|
||||
},
|
||||
'openInvalidMissing'
|
||||
);
|
||||
createActionButton('Invalid Scheme', function () {
|
||||
doOpen('x-ttp://www.invalid.com/', '_blank');
|
||||
}, 'openInvalidScheme');
|
||||
createActionButton('Invalid Host', function () {
|
||||
doOpen('http://www.inv;alid.com/', '_blank');
|
||||
}, 'openInvalidHost');
|
||||
createActionButton('Missing Local File', function () {
|
||||
doOpen('nonexistent.html', '_blank');
|
||||
}, 'openInvalidMissing');
|
||||
|
||||
// CSS / JS injection
|
||||
createActionButton(
|
||||
'Original Document',
|
||||
function () {
|
||||
doOpen(injecthtml, '_blank');
|
||||
},
|
||||
'openOriginalDocument'
|
||||
);
|
||||
createActionButton(
|
||||
'CSS File Injection',
|
||||
function () {
|
||||
openWithStyle(injecthtml, injectcss);
|
||||
},
|
||||
'openCSSInjection'
|
||||
);
|
||||
createActionButton(
|
||||
'CSS File Injection (callback)',
|
||||
function () {
|
||||
openWithStyle(injecthtml, injectcss, true);
|
||||
},
|
||||
'openCSSInjectionCallback'
|
||||
);
|
||||
createActionButton(
|
||||
'CSS Literal Injection',
|
||||
function () {
|
||||
openWithStyle(injecthtml);
|
||||
},
|
||||
'openCSSLiteralInjection'
|
||||
);
|
||||
createActionButton(
|
||||
'CSS Literal Injection (callback)',
|
||||
function () {
|
||||
openWithStyle(injecthtml, null, true);
|
||||
},
|
||||
'openCSSLiteralInjectionCallback'
|
||||
);
|
||||
createActionButton(
|
||||
'Script File Injection',
|
||||
function () {
|
||||
openWithScript(injecthtml, injectjs);
|
||||
},
|
||||
'openScriptInjection'
|
||||
);
|
||||
createActionButton(
|
||||
'Script File Injection (callback)',
|
||||
function () {
|
||||
openWithScript(injecthtml, injectjs, true);
|
||||
},
|
||||
'openScriptInjectionCallback'
|
||||
);
|
||||
createActionButton(
|
||||
'Script Literal Injection',
|
||||
function () {
|
||||
openWithScript(injecthtml);
|
||||
},
|
||||
'openScriptLiteralInjection'
|
||||
);
|
||||
createActionButton(
|
||||
'Script Literal Injection (callback)',
|
||||
function () {
|
||||
openWithScript(injecthtml, null, true);
|
||||
},
|
||||
'openScriptLiteralInjectionCallback'
|
||||
);
|
||||
createActionButton('Original Document', function () {
|
||||
doOpen(injecthtml, '_blank');
|
||||
}, 'openOriginalDocument');
|
||||
createActionButton('CSS File Injection', function () {
|
||||
openWithStyle(injecthtml, injectcss);
|
||||
}, 'openCSSInjection');
|
||||
createActionButton('CSS File Injection (callback)', function () {
|
||||
openWithStyle(injecthtml, injectcss, true);
|
||||
}, 'openCSSInjectionCallback');
|
||||
createActionButton('CSS Literal Injection', function () {
|
||||
openWithStyle(injecthtml);
|
||||
}, 'openCSSLiteralInjection');
|
||||
createActionButton('CSS Literal Injection (callback)', function () {
|
||||
openWithStyle(injecthtml, null, true);
|
||||
}, 'openCSSLiteralInjectionCallback');
|
||||
createActionButton('Script File Injection', function () {
|
||||
openWithScript(injecthtml, injectjs);
|
||||
}, 'openScriptInjection');
|
||||
createActionButton('Script File Injection (callback)', function () {
|
||||
openWithScript(injecthtml, injectjs, true);
|
||||
}, 'openScriptInjectionCallback');
|
||||
createActionButton('Script Literal Injection', function () {
|
||||
openWithScript(injecthtml);
|
||||
}, 'openScriptLiteralInjection');
|
||||
createActionButton('Script Literal Injection (callback)', function () {
|
||||
openWithScript(injecthtml, null, true);
|
||||
}, 'openScriptLiteralInjectionCallback');
|
||||
|
||||
// Open hidden
|
||||
createActionButton(
|
||||
'Create Hidden',
|
||||
function () {
|
||||
openHidden('https://www.google.co.uk', true);
|
||||
},
|
||||
'openHidden'
|
||||
);
|
||||
createActionButton(
|
||||
'Show Hidden',
|
||||
function () {
|
||||
showHidden();
|
||||
},
|
||||
'showHidden'
|
||||
);
|
||||
createActionButton(
|
||||
'Close Hidden',
|
||||
function () {
|
||||
closeHidden();
|
||||
},
|
||||
'closeHidden'
|
||||
);
|
||||
createActionButton(
|
||||
'google.co.uk Not Hidden',
|
||||
function () {
|
||||
openHidden('https://www.google.co.uk', false);
|
||||
},
|
||||
'openHiddenShow'
|
||||
);
|
||||
createActionButton(
|
||||
'google.co.uk shown for 2 seconds than hidden',
|
||||
function () {
|
||||
var iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
||||
setTimeout(function () {
|
||||
iab.hide();
|
||||
}, 2000);
|
||||
},
|
||||
'openVisibleAndHide'
|
||||
);
|
||||
createActionButton('Create Hidden', function () {
|
||||
openHidden('https://www.google.co.uk', true);
|
||||
}, 'openHidden');
|
||||
createActionButton('Show Hidden', function () {
|
||||
showHidden();
|
||||
}, 'showHidden');
|
||||
createActionButton('Close Hidden', function () {
|
||||
closeHidden();
|
||||
}, 'closeHidden');
|
||||
createActionButton('google.co.uk Not Hidden', function () {
|
||||
openHidden('https://www.google.co.uk', false);
|
||||
}, 'openHiddenShow');
|
||||
createActionButton('google.co.uk shown for 2 seconds than hidden', function () {
|
||||
var iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
||||
setTimeout(function () {
|
||||
iab.hide();
|
||||
}, 2000);
|
||||
}, 'openVisibleAndHide');
|
||||
|
||||
// Clearing cache
|
||||
createActionButton(
|
||||
'Clear Browser Cache',
|
||||
function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearcache=yes');
|
||||
},
|
||||
'openClearCache'
|
||||
);
|
||||
createActionButton(
|
||||
'Clear Session Cache',
|
||||
function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearsessioncache=yes');
|
||||
},
|
||||
'openClearSessionCache'
|
||||
);
|
||||
createActionButton('Clear Browser Cache', function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearcache=yes');
|
||||
}, 'openClearCache');
|
||||
createActionButton('Clear Session Cache', function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearsessioncache=yes');
|
||||
}, 'openClearSessionCache');
|
||||
|
||||
// Video tag
|
||||
createActionButton(
|
||||
'Remote Video',
|
||||
function () {
|
||||
doOpen(videohtml, '_blank');
|
||||
},
|
||||
'openRemoteVideo'
|
||||
);
|
||||
createActionButton(
|
||||
'Remote Need User No Video',
|
||||
function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no');
|
||||
},
|
||||
'openRemoteNeedUserNoVideo'
|
||||
);
|
||||
createActionButton(
|
||||
'Remote Need User Yes Video',
|
||||
function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes');
|
||||
},
|
||||
'openRemoteNeedUserYesVideo'
|
||||
);
|
||||
createActionButton('Remote Video', function () {
|
||||
doOpen(videohtml, '_blank');
|
||||
}, 'openRemoteVideo');
|
||||
createActionButton('Remote Need User No Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no');
|
||||
}, 'openRemoteNeedUserNoVideo');
|
||||
createActionButton('Remote Need User Yes Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes');
|
||||
}, 'openRemoteNeedUserYesVideo');
|
||||
|
||||
// Local With Anchor Tag
|
||||
createActionButton(
|
||||
'Anchor1',
|
||||
function () {
|
||||
doOpen(localhtml + '#bogusanchor', '_blank');
|
||||
},
|
||||
'openAnchor1'
|
||||
);
|
||||
createActionButton(
|
||||
'Anchor2',
|
||||
function () {
|
||||
doOpen(localhtml + '#anchor2', '_blank');
|
||||
},
|
||||
'openAnchor2'
|
||||
);
|
||||
createActionButton('Anchor1', function () {
|
||||
doOpen(localhtml + '#bogusanchor', '_blank');
|
||||
}, 'openAnchor1');
|
||||
createActionButton('Anchor2', function () {
|
||||
doOpen(localhtml + '#anchor2', '_blank');
|
||||
}, 'openAnchor2');
|
||||
|
||||
// Hardwareback
|
||||
createActionButton(
|
||||
'no hardwareback (defaults to yes)',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', '_blank');
|
||||
},
|
||||
'openHardwareBackDefault'
|
||||
);
|
||||
createActionButton(
|
||||
'hardwareback=yes',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=yes');
|
||||
},
|
||||
'openHardwareBackYes'
|
||||
);
|
||||
createActionButton(
|
||||
'hardwareback=no',
|
||||
function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=no');
|
||||
},
|
||||
'openHardwareBackNo'
|
||||
);
|
||||
createActionButton(
|
||||
'no hardwareback -> hardwareback=no -> no hardwareback',
|
||||
function () {
|
||||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
ref.addEventListener('loadstop', function () {
|
||||
ref.close();
|
||||
createActionButton('no hardwareback (defaults to yes)', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank');
|
||||
}, 'openHardwareBackDefault');
|
||||
createActionButton('hardwareback=yes', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=yes');
|
||||
}, 'openHardwareBackYes');
|
||||
createActionButton('hardwareback=no', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=no');
|
||||
}, 'openHardwareBackNo');
|
||||
createActionButton('no hardwareback -> hardwareback=no -> no hardwareback', function () {
|
||||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
ref.addEventListener('loadstop', function () {
|
||||
ref.close();
|
||||
});
|
||||
ref.addEventListener('exit', function () {
|
||||
var ref2 = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes,hardwareback=no' + (platformOpts ? ',' + platformOpts : ''));
|
||||
ref2.addEventListener('loadstop', function () {
|
||||
ref2.close();
|
||||
});
|
||||
ref.addEventListener('exit', function () {
|
||||
var ref2 = cordova.InAppBrowser.open(
|
||||
'https://google.com',
|
||||
'_blank',
|
||||
'location=yes,hardwareback=no' + (platformOpts ? ',' + platformOpts : '')
|
||||
);
|
||||
ref2.addEventListener('loadstop', function () {
|
||||
ref2.close();
|
||||
});
|
||||
ref2.addEventListener('exit', function () {
|
||||
cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
});
|
||||
ref2.addEventListener('exit', function () {
|
||||
cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
});
|
||||
},
|
||||
'openHardwareBackDefaultAfterNo'
|
||||
);
|
||||
});
|
||||
}, 'openHardwareBackDefaultAfterNo');
|
||||
};
|
||||
|
||||
Vendored
+7
-6
@@ -8,12 +8,7 @@
|
||||
// TypeScript Version: 2.3
|
||||
type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message" | "customscheme";
|
||||
|
||||
/**
|
||||
* The object returned from a call to cordova.InAppBrowser.open.
|
||||
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
|
||||
*/
|
||||
interface InAppBrowser {
|
||||
|
||||
interface Window {
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
@@ -23,7 +18,13 @@ interface InAppBrowser {
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
*/
|
||||
open(url: string, target?: string, options?: string): InAppBrowser;
|
||||
}
|
||||
|
||||
/**
|
||||
* The object returned from a call to window.open.
|
||||
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
|
||||
*/
|
||||
interface InAppBrowser extends Window {
|
||||
onloadstart(type: Event): void;
|
||||
onloadstop(type: InAppBrowserEvent): void;
|
||||
onloaderror(type: InAppBrowserEvent): void;
|
||||
|
||||
+9
-9
@@ -17,7 +17,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var exec = require('cordova/exec');
|
||||
@@ -27,19 +27,19 @@
|
||||
|
||||
function InAppBrowser () {
|
||||
this.channels = {
|
||||
beforeload: channel.create('beforeload'),
|
||||
loadstart: channel.create('loadstart'),
|
||||
loadstop: channel.create('loadstop'),
|
||||
loaderror: channel.create('loaderror'),
|
||||
exit: channel.create('exit'),
|
||||
customscheme: channel.create('customscheme'),
|
||||
message: channel.create('message')
|
||||
'beforeload': channel.create('beforeload'),
|
||||
'loadstart': channel.create('loadstart'),
|
||||
'loadstop': channel.create('loadstop'),
|
||||
'loaderror': channel.create('loaderror'),
|
||||
'exit': channel.create('exit'),
|
||||
'customscheme': channel.create('customscheme'),
|
||||
'message': channel.create('message')
|
||||
};
|
||||
}
|
||||
|
||||
InAppBrowser.prototype = {
|
||||
_eventHandler: function (event) {
|
||||
if (event && event.type in this.channels) {
|
||||
if (event && (event.type in this.channels)) {
|
||||
if (event.type === 'beforeload') {
|
||||
this.channels[event.type].fire(event, this._loadAfterBeforeload);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user