Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bc15de222 | |||
| 31860cf6c3 | |||
| d735e136cd | |||
| 65e86c7e1b | |||
| d533f2a953 | |||
| b18b9794a8 | |||
| ac16f78b15 | |||
| ec16fee79f | |||
| 178f2d3e59 | |||
| 1e8599a32a | |||
| 8ee1d38821 | |||
| 405468cb2d | |||
| a877f62d62 | |||
| bd02f45383 | |||
| dfcffb4812 | |||
| 1718efa138 | |||
| 0f468c7393 | |||
| 2043109c16 | |||
| 89c5a6a21b | |||
| 9bc8f7629e | |||
| 2fef3046fc | |||
| 3b6757fc44 | |||
| 10f2ad72a0 | |||
| 6b920849cc | |||
| 07862603eb | |||
| b496e03169 | |||
| 80720a0850 | |||
| de31942e6c | |||
| 8bdbd18d16 | |||
| 11b1347812 | |||
| 85acc2a12a | |||
| 02909a7f16 | |||
| 8a29d884c3 | |||
| af8d268ce4 | |||
| e1d0777ea0 | |||
| 2e6d63751f | |||
| 1020b8f642 | |||
| 46c080f59a | |||
| 2a1c0c0591 | |||
| 043f96a47e | |||
| b7ea751ba9 | |||
| edd7250c83 | |||
| deb8fbe776 | |||
| 2a28e09a70 | |||
| 91ebdf2776 | |||
| ab8fb4417c | |||
| 2fb0a368ed | |||
| 7c2810e885 | |||
| bdbb1df44c | |||
| 6d60e4c6eb | |||
| d5fba787d4 |
@@ -1,33 +0,0 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: "10"
|
||||
- nodejs_version: "12"
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
install:
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
- node --version
|
||||
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
|
||||
- npm install -g cordova
|
||||
- npm install
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\windows-10-store --plugin . --justBuild
|
||||
@@ -15,6 +15,32 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
github:
|
||||
description: Apache Cordova InAppBrowser Plugin
|
||||
homepage: https://cordova.apache.org/
|
||||
|
||||
labels:
|
||||
- android
|
||||
- cordova
|
||||
- hacktoberfest
|
||||
- ios
|
||||
- java
|
||||
- javascript
|
||||
- library
|
||||
- mobile
|
||||
- nodejs
|
||||
- objective-c
|
||||
|
||||
features:
|
||||
wiki: false
|
||||
issues: true
|
||||
projects: true
|
||||
|
||||
enabled_merge_buttons:
|
||||
squash: true
|
||||
merge: false
|
||||
rebase: false
|
||||
|
||||
notifications:
|
||||
commits: commits@cordova.apache.org
|
||||
issues: issues@cordova.apache.org
|
||||
|
||||
+22
-9
@@ -1,10 +1,23 @@
|
||||
# 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: semistandard
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
camelcase: off
|
||||
padded-blocks: off
|
||||
operator-linebreak: off
|
||||
no-throw-literal: off
|
||||
extends: '@cordova/eslint-config/browser'
|
||||
|
||||
overrides:
|
||||
- files: [tests/**/*.js]
|
||||
extends: '@cordova/eslint-config/node-tests'
|
||||
|
||||
@@ -13,7 +13,8 @@ For usage and support questions, please check out the resources below. Thanks!
|
||||
|
||||
You can get answers to your usage and support questions about **Apache Cordova** on:
|
||||
|
||||
* Slack Community Chat: https://cordova.slack.com (you can sign-up at http://slack.cordova.io/)
|
||||
* GitHub Discussions: https://github.com/apache/cordova/discussions
|
||||
* Slack Community Chat: https://cordova.slack.com (you can sign-up at https://s.apache.org/cordova-slack)
|
||||
* StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova`
|
||||
|
||||
---
|
||||
@@ -22,6 +23,4 @@ If you are using a tool that uses Cordova internally, like e.g. Ionic, check the
|
||||
|
||||
* **Ionic Framework**
|
||||
* [Ionic Community Forum](https://forum.ionicframework.com/)
|
||||
* [Ionic Worldwide Slack](https://ionicworldwide.herokuapp.com/)
|
||||
* **PhoneGap**
|
||||
* [PhoneGap Developer Community](https://forums.adobe.com/community/phonegap)
|
||||
* [Ionic Discord](https://ionic.link/discord)
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# 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.
|
||||
|
||||
name: Android Testsuite
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
- '.eslint*'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
- '.eslint*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Android ${{ matrix.versions.android }} Test
|
||||
runs-on: macos-latest
|
||||
continue-on-error: true
|
||||
|
||||
# hoist configurations to top that are expected to be updated
|
||||
env:
|
||||
# Storing a copy of the repo
|
||||
repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
|
||||
|
||||
node-version: 16
|
||||
|
||||
# These are the default Java configurations used by most tests.
|
||||
# To customize these options, add "java-distro" or "java-version" to the strategy matrix with its overriding value.
|
||||
default_java-distro: temurin
|
||||
default_java-version: 11
|
||||
|
||||
# These are the default Android System Image configurations used by most tests.
|
||||
# To customize these options, add "system-image-arch" or "system-image-target" to the strategy matrix with its overriding value.
|
||||
default_system-image-arch: x86_64
|
||||
default_system-image-target: google_apis # Most system images have a google_api option. Set this as default.
|
||||
|
||||
# configurations for each testing strategy (test matrix)
|
||||
strategy:
|
||||
matrix:
|
||||
versions:
|
||||
# Test the lowest minimum supported APIs
|
||||
- android: 7
|
||||
android-api: 24
|
||||
|
||||
# Test the last 3-4 supported APIs
|
||||
- android: 10
|
||||
android-api: 29
|
||||
|
||||
- android: 11
|
||||
android-api: 30
|
||||
|
||||
- android: 12L
|
||||
android-api: 32
|
||||
|
||||
- android: 13
|
||||
android-api: 33
|
||||
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.node-version }}
|
||||
- uses: actions/setup-java@v3
|
||||
env:
|
||||
java-version: ${{ matrix.versions.java-version == '' && env.default_java-version || matrix.versions.java-version }}
|
||||
java-distro: ${{ matrix.versions.java-distro == '' && env.default_java-distro || matrix.versions.java-distro }}
|
||||
with:
|
||||
distribution: ${{ env.java-distro }}
|
||||
java-version: ${{ env.java-version }}
|
||||
|
||||
- name: Run Environment Information
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
java -version
|
||||
|
||||
- name: Run npm install
|
||||
run: |
|
||||
export PATH="/usr/local/lib/android/sdk/platform-tools":$PATH
|
||||
export JAVA_HOME=$JAVA_HOME_11_X64
|
||||
npm i -g cordova@latest
|
||||
npm ci
|
||||
|
||||
- name: Run paramedic install
|
||||
if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
|
||||
run: npm i -g github:apache/cordova-paramedic
|
||||
|
||||
- uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b
|
||||
env:
|
||||
system-image-arch: ${{ matrix.versions.system-image-arch == '' && env.default_system-image-arch || matrix.versions.system-image-arch }}
|
||||
system-image-target: ${{ matrix.versions.system-image-target == '' && env.default_system-image-target || matrix.versions.system-image-target }}
|
||||
with:
|
||||
api-level: ${{ matrix.versions.android-api }}
|
||||
target: ${{ env.system-image-target }}
|
||||
arch: ${{ env.system-image-arch }}
|
||||
force-avd-creation: false
|
||||
disable-animations: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
|
||||
script: echo "Pregenerate the AVD before running Paramedic"
|
||||
|
||||
- name: Run paramedic tests
|
||||
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b
|
||||
env:
|
||||
system-image-arch: ${{ matrix.versions.system-image-arch == '' && env.default_system-image-arch || matrix.versions.system-image-arch }}
|
||||
system-image-target: ${{ matrix.versions.system-image-target == '' && env.default_system-image-target || matrix.versions.system-image-target }}
|
||||
test_config: 'android-${{ matrix.versions.android }}.config.json'
|
||||
# Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
|
||||
test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
|
||||
paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
|
||||
with:
|
||||
api-level: ${{ matrix.versions.android-api }}
|
||||
target: ${{ env.system-image-target }}
|
||||
arch: ${{ env.system-image-arch }}
|
||||
force-avd-creation: false
|
||||
disable-animations: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
|
||||
script: ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}
|
||||
@@ -0,0 +1,73 @@
|
||||
# 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.
|
||||
|
||||
name: Chrome Testsuite
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
- '.eslint*'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
- '.eslint*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Chrome Latest Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# hoist configurations to top that are expected to be updated
|
||||
env:
|
||||
# Storing a copy of the repo
|
||||
repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
|
||||
|
||||
node-version: 16
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.node-version }}
|
||||
|
||||
- name: Run install xvfb
|
||||
run: sudo apt-get install xvfb
|
||||
|
||||
- name: Run Environment Information
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run npm install
|
||||
run: |
|
||||
npm i -g cordova@latest
|
||||
npm ci
|
||||
|
||||
- name: Run paramedic install
|
||||
if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
|
||||
run: npm i -g github:apache/cordova-paramedic
|
||||
|
||||
- name: Run paramedic tests
|
||||
env:
|
||||
test_config: 'browser.config.json'
|
||||
# Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
|
||||
test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
|
||||
paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
|
||||
run: xvfb-run --auto-servernum ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}
|
||||
@@ -0,0 +1,101 @@
|
||||
# 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.
|
||||
|
||||
name: iOS Testsuite
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
- '.eslint*'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
- '.eslint*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: iOS ${{ matrix.versions.ios-version }} Test
|
||||
runs-on: ${{ matrix.versions.os-version }}
|
||||
continue-on-error: true
|
||||
|
||||
# hoist configurations to top that are expected to be updated
|
||||
env:
|
||||
# Storing a copy of the repo
|
||||
repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
|
||||
|
||||
node-version: 16
|
||||
|
||||
# > Starting April 26, 2021, all iOS and iPadOS apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK.
|
||||
# Because of Apple's requirement, listed above, We will only be using the latest Xcode release for testing.
|
||||
# To customize these options, add "xcode-version" to the strategy matrix with its overriding value.
|
||||
default_xcode-version: latest-stable
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
versions:
|
||||
- os-version: macos-11
|
||||
ios-version: 13.x
|
||||
xcode-version: 11.x
|
||||
|
||||
- os-version: macos-11
|
||||
ios-version: 14.x
|
||||
xcode-version: 12.x
|
||||
|
||||
- os-version: macos-11
|
||||
ios-version: 15.x
|
||||
xcode-version: 13.x
|
||||
|
||||
- os-version: macos-12
|
||||
ios-version: 16.x
|
||||
xcode-version: 14.x
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ env.node-version }}
|
||||
- uses: maxim-lobanov/setup-xcode@9a697e2b393340c3cacd97468baa318e4c883d98
|
||||
env:
|
||||
xcode-version: ${{ matrix.versions.xcode-version == '' && env.default_xcode-version || matrix.versions.xcode-version }}
|
||||
with:
|
||||
xcode-version: ${{ env.xcode-version }}
|
||||
|
||||
- name: Run Environment Information
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
xcodebuild -version
|
||||
|
||||
- name: Run npm install
|
||||
run: |
|
||||
npm i -g cordova@latest ios-deploy@latest
|
||||
npm ci
|
||||
|
||||
- name: Run paramedic install
|
||||
if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
|
||||
run: npm i -g github:apache/cordova-paramedic
|
||||
|
||||
- name: Run paramedic tests
|
||||
env:
|
||||
test_config: 'ios-${{ matrix.versions.ios-version }}.config.json'
|
||||
# Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
|
||||
test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
|
||||
paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
|
||||
run: ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}
|
||||
@@ -0,0 +1,56 @@
|
||||
# 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.
|
||||
|
||||
name: Lint Test
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.js'
|
||||
- '.eslint*'
|
||||
- '.github/workflow/lint.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.js'
|
||||
- '.eslint*'
|
||||
- '.github/workflow/lint.yml'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Lint Test
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
node-version: 16
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.node-version }}
|
||||
|
||||
- name: Run Environment Information
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run npm install
|
||||
run: |
|
||||
npm ci
|
||||
|
||||
- name: Run lint test
|
||||
run: |
|
||||
npm run lint
|
||||
@@ -1,3 +1,2 @@
|
||||
.*
|
||||
appveyor.yml
|
||||
tests
|
||||
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
# This Travis configuration file is built after a Cordova Paramedic
|
||||
# specific template with minimal modifications and adaptations:
|
||||
# https://github.com/apache/cordova-paramedic/blob/master/.travis.yml
|
||||
|
||||
sudo: false
|
||||
|
||||
addons:
|
||||
jwt:
|
||||
# SAUCE_ACCESS_KEY
|
||||
secure: TZ88IEvAw1bsWPWxvDzXdpi2NK0i3PN4hG15+vDpIt6wXGVPknjxuXWJeLj7TqBpAIvP7XDfS8ZvHVPLe7fe8oOchZPLuiDw9VVIk6cnHjE6wpoavdGc/1mDJ3Bi4PDcHwRUr5ng5spYQqqlTwcECkH/q7iPgudiFM6rlOlGRyA=
|
||||
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION=12
|
||||
- ANDROID_API_LEVEL=28
|
||||
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
|
||||
|
||||
language: node_js
|
||||
node_js: 12
|
||||
|
||||
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
|
||||
|
||||
_ios: &_ios
|
||||
os: osx
|
||||
osx_image: xcode10.3
|
||||
|
||||
_android: &_android
|
||||
language: android
|
||||
os: linux
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
|
||||
- android-$ANDROID_API_LEVEL
|
||||
licenses:
|
||||
- "android-sdk-preview-license-.+"
|
||||
- "android-sdk-license-.+"
|
||||
- "google-gdk-license-.+"
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# local tests, without saucelabs
|
||||
- env: PLATFORM=local/browser
|
||||
<<: *_ios
|
||||
- env: PLATFORM=local/ios-10.0
|
||||
<<: *_ios
|
||||
|
||||
# many tests with saucelabs
|
||||
- env: PLATFORM=browser-chrome
|
||||
- env: PLATFORM=browser-firefox
|
||||
- env: PLATFORM=browser-safari
|
||||
- env: PLATFORM=browser-edge
|
||||
|
||||
- env: PLATFORM=ios-11.3
|
||||
<<: *_ios
|
||||
- env: PLATFORM=ios-12.0
|
||||
<<: *_ios
|
||||
|
||||
- env: PLATFORM=android-5.1
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-6.0
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-7.0
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-7.1
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-8.0
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-8.1
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-9.0
|
||||
<<: *_android
|
||||
|
||||
before_install:
|
||||
# manually install Node for `language: android`
|
||||
- if [[ "$PLATFORM" =~ android ]]; then nvm install $TRAVIS_NODE_VERSION; fi
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- npm install -g cordova
|
||||
# install paramedic if not running on paramedic repo
|
||||
- if ! [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then npm install -g github:apache/cordova-paramedic; fi
|
||||
|
||||
install:
|
||||
- npm install
|
||||
|
||||
before_script:
|
||||
- |
|
||||
if [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then
|
||||
# when used in the cordova-paramedic repo
|
||||
TEST_COMMAND="npm run eslint"
|
||||
PARAMEDIC_PLUGIN_TO_TEST="./spec/testable-plugin/"
|
||||
PARAMEDIC_COMMAND="node main.js"
|
||||
else
|
||||
# when used in any other (plugin) repo
|
||||
TEST_COMMAND="npm test"
|
||||
PARAMEDIC_PLUGIN_TO_TEST=$(pwd)
|
||||
PARAMEDIC_COMMAND="cordova-paramedic"
|
||||
fi
|
||||
- PARAMEDIC_BUILDNAME=travis-$TRAVIS_REPO_SLUG-$TRAVIS_JOB_NUMBER
|
||||
- |
|
||||
echo "Variables now are set to:"
|
||||
echo "TEST_COMMAND=$TEST_COMMAND"
|
||||
echo "ADDITIONAL_TESTS=$ADDITIONAL_TESTS"
|
||||
echo "PARAMEDIC_COMMAND=$PARAMEDIC_COMMAND"
|
||||
echo "PLATFORM=$PLATFORM"
|
||||
echo "PARAMEDIC_PLUGIN_TO_TEST=$PARAMEDIC_PLUGIN_TO_TEST"
|
||||
echo "PARAMEDIC_BUILDNAME=$PARAMEDIC_BUILDNAME"
|
||||
script:
|
||||
- $TEST_COMMAND
|
||||
- |
|
||||
if [[ "$ADDITIONAL_TESTS_DIR" != "" ]]; then
|
||||
cd $ADDITIONAL_TESTS_DIR && npm install && npm test;
|
||||
else
|
||||
$PARAMEDIC_COMMAND --config ./pr/$PLATFORM --plugin $PARAMEDIC_PLUGIN_TO_TEST --buildName $PARAMEDIC_BUILDNAME;
|
||||
fi
|
||||
@@ -21,19 +21,18 @@ description: Open an in-app browser window.
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
|AppVeyor|Travis CI|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-inappbrowser)|[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)|
|
||||
|
||||
# cordova-plugin-inappbrowser
|
||||
|
||||
[](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/android.yml) [](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/chrome.yml) [](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/ios.yml) [](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/lint.yml)
|
||||
|
||||
You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app.
|
||||
|
||||
> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content.
|
||||
|
||||
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
|
||||
### `window.open`
|
||||
|
||||
@@ -68,6 +67,14 @@ 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', 'darkcontent' or 'default'. Defaults to 'default') set text color style for iOS. 'lightcontent' is intended for use on dark backgrounds. 'darkcontent' is only available since iOS 13 and intended for use on light backgrounds.
|
||||
```xml
|
||||
<preference name="InAppBrowserStatusBarStyle" value="lightcontent" />
|
||||
```
|
||||
|
||||
## cordova.InAppBrowser.open
|
||||
|
||||
Opens a URL in a new `InAppBrowser` instance, the current browser
|
||||
@@ -159,7 +166,7 @@ instance, or the system browser.
|
||||
|
||||
### Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
var ref2 = cordova.InAppBrowser.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes');
|
||||
|
||||
### OSX Quirks
|
||||
@@ -168,6 +175,16 @@ 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,
|
||||
@@ -204,6 +221,7 @@ The object returned from a call to `cordova.InAppBrowser.open` when the target i
|
||||
- __exit__: event fires when the `InAppBrowser` window is closed.
|
||||
- __beforeload__: event fires when the `InAppBrowser` decides whether to load an URL or not (only with option `beforeload` set).
|
||||
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
|
||||
- __download__: _(Android Only)_ event fires when the `InAppBrowser` loads a URL that leads in downloading of a file.
|
||||
|
||||
- __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter.
|
||||
|
||||
@@ -304,20 +322,43 @@ function messageCallBack(params){
|
||||
}
|
||||
|
||||
```
|
||||
#### Download event Example
|
||||
|
||||
Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assigned to the "download" event is called. The parameter passed to this callback is an object with the the following properties
|
||||
|
||||
- **type** _it contains the String value "download" always_
|
||||
- **url** _The url that leaded to the downloading of file. Basically, the download link of file_
|
||||
- **userAgent** _User Agent of the webview_
|
||||
- **contentDisposition** _If the url contains "content-disposition" header, then this property holds the value of that field else this field is empty_
|
||||
- **contentLength** _If the link of the file allows to obtain file size then this property holds the file size else it contains int value 0_
|
||||
- **mimetype** _The MIME type of the file_
|
||||
|
||||
```
|
||||
|
||||
function downloadListener(params){
|
||||
var url = params.url;
|
||||
var mimetype = params.mimetype;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", params.url);
|
||||
xhr.onload = function() {
|
||||
var content = xhr.responseText;
|
||||
};
|
||||
xhr.send();
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
### InAppBrowserEvent Properties
|
||||
|
||||
- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, `message` or `exit`. _(String)_
|
||||
|
||||
- __url__: the URL that was loaded. _(String)_
|
||||
|
||||
- __code__: the error code, only in the case of `loaderror`. _(Number)_
|
||||
|
||||
- __message__: the error message, only in the case of `loaderror`. _(String)_
|
||||
|
||||
- __data__: the message contents , only in the case of `message`. A stringified JSON object. _(String)_
|
||||
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
@@ -336,7 +377,7 @@ function messageCallBack(params){
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstart', function(event) { alert(event.url); });
|
||||
|
||||
## InAppBrowser.removeEventListener
|
||||
@@ -354,6 +395,7 @@ function messageCallBack(params){
|
||||
- __loaderror__: event fires when the `InAppBrowser` encounters an error loading a URL.
|
||||
- __exit__: event fires when the `InAppBrowser` window is closed.
|
||||
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
|
||||
- __download__: _(Android only)_ event fires when the `InAppBrowser` loads a URL that leads in downloading of a file.
|
||||
|
||||
- __callback__: the function to execute when the event fires.
|
||||
The function is passed an `InAppBrowserEvent` object.
|
||||
@@ -367,7 +409,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
var myCallback = function(event) { alert(event.url); }
|
||||
ref.addEventListener('loadstart', myCallback);
|
||||
ref.removeEventListener('loadstart', myCallback);
|
||||
@@ -389,7 +431,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
ref.close();
|
||||
|
||||
## InAppBrowser.show
|
||||
@@ -409,7 +451,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'hidden=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'hidden=yes');
|
||||
// some time later...
|
||||
ref.show();
|
||||
|
||||
@@ -429,7 +471,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank');
|
||||
// some time later...
|
||||
ref.hide();
|
||||
|
||||
@@ -461,7 +503,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.executeScript({file: "myscript.js"});
|
||||
});
|
||||
@@ -496,7 +538,7 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.insertCSS({file: "mystyles.css"});
|
||||
});
|
||||
@@ -678,13 +720,13 @@ iab.open('local-url.html', 'random_string', 'location=no'); // loads in the InAp
|
||||
```
|
||||
var iab = cordova.InAppBrowser;
|
||||
|
||||
iab.open('http://whitelisted-url.com'); // loads in the Cordova WebView
|
||||
iab.open('http://whitelisted-url.com', '_self'); // loads in the Cordova WebView
|
||||
iab.open('http://whitelisted-url.com', '_system'); // loads in the system browser
|
||||
iab.open('http://whitelisted-url.com', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('http://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser
|
||||
iab.open('https://whitelisted-url.com'); // loads in the Cordova WebView
|
||||
iab.open('https://whitelisted-url.com', '_self'); // loads in the Cordova WebView
|
||||
iab.open('https://whitelisted-url.com', '_system'); // loads in the system browser
|
||||
iab.open('https://whitelisted-url.com', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('https://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser
|
||||
|
||||
iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
iab.open('https://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
|
||||
```
|
||||
|
||||
@@ -693,11 +735,11 @@ iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads
|
||||
```
|
||||
var iab = cordova.InAppBrowser;
|
||||
|
||||
iab.open('http://url-that-fails-whitelist.com'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', '_system'); // loads in the system browser
|
||||
iab.open('http://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
iab.open('https://url-that-fails-whitelist.com'); // loads in the InAppBrowser
|
||||
iab.open('https://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser
|
||||
iab.open('https://url-that-fails-whitelist.com', '_system'); // loads in the system browser
|
||||
iab.open('https://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('https://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser
|
||||
iab.open('https://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
|
||||
```
|
||||
|
||||
@@ -20,6 +20,31 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 5.0.0 (Feb 10, 2021)
|
||||
* [GH-828](https://github.com/apache/cordova-plugin-inappbrowser/pull/828) feat(ios): add `InAppBrowser`StatusBarStyle 'darkcontent' configuration option
|
||||
* [GH-823](https://github.com/apache/cordova-plugin-inappbrowser/pull/823) chore: bump engines requirements
|
||||
* [GH-824](https://github.com/apache/cordova-plugin-inappbrowser/pull/824) breaking: cleanup code for old **Android** versions
|
||||
* [GH-825](https://github.com/apache/cordova-plugin-inappbrowser/pull/825) (ios): rename CDVWKProcessPoolFactory
|
||||
* [GH-826](https://github.com/apache/cordova-plugin-inappbrowser/pull/826) ci: add node-14.x to workflow
|
||||
* [GH-821](https://github.com/apache/cordova-plugin-inappbrowser/pull/821) breaking(android): replace magic numbers with **Android**.os.Build constants
|
||||
* [GH-717](https://github.com/apache/cordova-plugin-inappbrowser/pull/717) ci(ios): remove wkwebview plugin
|
||||
|
||||
### 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
|
||||
|
||||
Generated
+4186
File diff suppressed because it is too large
Load Diff
+11
-17
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "4.0.0",
|
||||
"version": "5.1.0-dev",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
@@ -13,13 +13,8 @@
|
||||
"windows"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser/issues"
|
||||
},
|
||||
"repository": "github:apache/cordova-plugin-inappbrowser",
|
||||
"bugs": "https://github.com/apache/cordova-plugin-inappbrowser/issues",
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"in",
|
||||
@@ -34,8 +29,8 @@
|
||||
"cordova-windows"
|
||||
],
|
||||
"scripts": {
|
||||
"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"
|
||||
"test": "npm run lint",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
@@ -47,6 +42,11 @@
|
||||
"cordova-ios": ">=4.0.0"
|
||||
},
|
||||
"5.0.0": {
|
||||
"cordova-android": ">=9.0.0",
|
||||
"cordova-ios": ">=6.0.0",
|
||||
"cordova": ">=9.0.0"
|
||||
},
|
||||
"6.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
@@ -54,12 +54,6 @@
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"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"
|
||||
"@cordova/eslint-config": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="4.0.0">
|
||||
version="5.1.0-dev">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
@@ -30,8 +30,9 @@
|
||||
<issue>https://github.com/apache/cordova-plugin-inappbrowser/issues</issue>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
|
||||
<engine name="cordova-ios" version=">=4.0.0" />
|
||||
<engine name="cordova" version=">=9.0.0"/>
|
||||
<engine name="cordova-android" version=">=9.0.0" />
|
||||
<engine name="cordova-ios" version=">=6.0.0" />
|
||||
</engines>
|
||||
|
||||
<!-- android -->
|
||||
|
||||
+61
-119
@@ -20,7 +20,6 @@ package org.apache.cordova.inappbrowser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -30,8 +29,6 @@ import android.provider.Browser;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Color;
|
||||
import android.net.http.SslError;
|
||||
import android.net.Uri;
|
||||
@@ -48,7 +45,6 @@ import android.view.WindowManager.LayoutParams;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.SslErrorHandler;
|
||||
@@ -58,6 +54,7 @@ import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
@@ -101,6 +98,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private static final String LOAD_START_EVENT = "loadstart";
|
||||
private static final String LOAD_STOP_EVENT = "loadstop";
|
||||
private static final String LOAD_ERROR_EVENT = "loaderror";
|
||||
private static final String DOWNLOAD_EVENT = "download";
|
||||
private static final String MESSAGE_EVENT = "message";
|
||||
private static final String CLEAR_ALL_CACHE = "clearcache";
|
||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||
@@ -121,6 +119,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private static final String BEFORELOAD = "beforeload";
|
||||
private static final String FULLSCREEN = "fullscreen";
|
||||
|
||||
private static final int TOOLBAR_HEIGHT = 48;
|
||||
|
||||
private static final List customizableOptions = Arrays.asList(CLOSE_BUTTON_CAPTION, TOOLBAR_COLOR, NAVIGATION_COLOR, CLOSE_BUTTON_COLOR, FOOTER_COLOR);
|
||||
|
||||
private InAppBrowserDialog dialog;
|
||||
@@ -136,10 +136,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private boolean mediaPlaybackRequiresUserGesture = false;
|
||||
private boolean shouldPauseInAppBrowser = false;
|
||||
private boolean useWideViewPort = true;
|
||||
private ValueCallback<Uri> mUploadCallback;
|
||||
private ValueCallback<Uri[]> mUploadCallbackLollipop;
|
||||
private ValueCallback<Uri[]> mUploadCallback;
|
||||
private final static int FILECHOOSER_REQUESTCODE = 1;
|
||||
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
|
||||
private String closeButtonCaption = "";
|
||||
private String closeButtonColor = "";
|
||||
private boolean leftToRight = false;
|
||||
@@ -276,6 +274,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
|
||||
}
|
||||
inAppWebView.loadUrl(url);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -414,12 +413,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void run() {
|
||||
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 {
|
||||
inAppWebView.evaluateJavascript(finalScriptToInject, null);
|
||||
}
|
||||
inAppWebView.evaluateJavascript(finalScriptToInject, null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -762,8 +756,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
if (closeButtonColor != "") close.setColorFilter(android.graphics.Color.parseColor(closeButtonColor));
|
||||
close.setImageDrawable(closeIcon);
|
||||
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
close.getAdjustViewBounds();
|
||||
close.getAdjustViewBounds();
|
||||
|
||||
_close = close;
|
||||
}
|
||||
@@ -772,11 +765,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
if (leftToRight) closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
||||
else closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
_close.setLayoutParams(closeLayoutParams);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
_close.setBackground(null);
|
||||
else
|
||||
_close.setBackgroundDrawable(null);
|
||||
_close.setBackground(null);
|
||||
|
||||
_close.setContentDescription("Close Button");
|
||||
_close.setId(Integer.valueOf(id));
|
||||
@@ -815,7 +804,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
|
||||
//Please, no more black!
|
||||
toolbar.setBackgroundColor(toolbarColor);
|
||||
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
|
||||
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(TOOLBAR_HEIGHT)));
|
||||
toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
|
||||
if (leftToRight) {
|
||||
toolbar.setHorizontalGravity(Gravity.LEFT);
|
||||
@@ -845,15 +834,11 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable backIcon = activityRes.getDrawable(backResId);
|
||||
if (navigationButtonColor != "") back.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
back.setBackground(null);
|
||||
else
|
||||
back.setBackgroundDrawable(null);
|
||||
back.setBackground(null);
|
||||
back.setImageDrawable(backIcon);
|
||||
back.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
back.getAdjustViewBounds();
|
||||
back.getAdjustViewBounds();
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
@@ -871,15 +856,11 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
|
||||
if (navigationButtonColor != "") forward.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
forward.setBackground(null);
|
||||
else
|
||||
forward.setBackgroundDrawable(null);
|
||||
forward.setBackground(null);
|
||||
forward.setImageDrawable(fwdIcon);
|
||||
forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
forward.getAdjustViewBounds();
|
||||
forward.getAdjustViewBounds();
|
||||
|
||||
forward.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
@@ -925,7 +906,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
_footerColor = android.graphics.Color.LTGRAY;
|
||||
}
|
||||
footer.setBackgroundColor(_footerColor);
|
||||
RelativeLayout.LayoutParams footerLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44));
|
||||
RelativeLayout.LayoutParams footerLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(TOOLBAR_HEIGHT));
|
||||
footerLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
|
||||
footer.setLayoutParams(footerLayout);
|
||||
if (closeButtonCaption != "") footer.setPadding(this.dpToPixels(8), this.dpToPixels(8), this.dpToPixels(8), this.dpToPixels(8));
|
||||
@@ -935,22 +916,20 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
View footerClose = createCloseButton(7);
|
||||
footer.addView(footerClose);
|
||||
|
||||
|
||||
// WebView
|
||||
inAppWebView = new WebView(cordova.getActivity());
|
||||
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
inAppWebView.setId(Integer.valueOf(6));
|
||||
// File Chooser Implemented ChromeClient
|
||||
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
|
||||
// For Android 5.0+
|
||||
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
|
||||
{
|
||||
LOG.d(LOG_TAG, "File Chooser 5.0+");
|
||||
// If callback exists, finish it.
|
||||
if(mUploadCallbackLollipop != null) {
|
||||
mUploadCallbackLollipop.onReceiveValue(null);
|
||||
if(mUploadCallback != null) {
|
||||
mUploadCallback.onReceiveValue(null);
|
||||
}
|
||||
mUploadCallbackLollipop = filePathCallback;
|
||||
mUploadCallback = filePathCallback;
|
||||
|
||||
// Create File Chooser Intent
|
||||
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
@@ -958,30 +937,9 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
content.setType("*/*");
|
||||
|
||||
// Run cordova startActivityForResult
|
||||
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
|
||||
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// For Android 4.1+
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
|
||||
{
|
||||
LOG.d(LOG_TAG, "File Chooser 4.1+");
|
||||
// Call file chooser for Android 3.0+
|
||||
openFileChooser(uploadMsg, acceptType);
|
||||
}
|
||||
|
||||
// For Android 3.0+
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
|
||||
{
|
||||
LOG.d(LOG_TAG, "File Chooser 3.0+");
|
||||
mUploadCallback = uploadMsg;
|
||||
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
content.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
|
||||
// run startActivityForResult
|
||||
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
|
||||
}
|
||||
|
||||
});
|
||||
currentClient = new InAppBrowserClient(thatWebView, edittext, beforeload);
|
||||
inAppWebView.setWebViewClient(currentClient);
|
||||
@@ -990,6 +948,30 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||
settings.setBuiltInZoomControls(showZoomControls);
|
||||
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
|
||||
|
||||
// download event
|
||||
|
||||
inAppWebView.setDownloadListener(
|
||||
new DownloadListener(){
|
||||
public void onDownloadStart(
|
||||
String url, String userAgent, String contentDisposition, String mimetype, long contentLength
|
||||
){
|
||||
try{
|
||||
JSONObject succObj = new JSONObject();
|
||||
succObj.put("type", DOWNLOAD_EVENT);
|
||||
succObj.put("url",url);
|
||||
succObj.put("userAgent",userAgent);
|
||||
succObj.put("contentDisposition",contentDisposition);
|
||||
succObj.put("mimetype",mimetype);
|
||||
succObj.put("contentLength",contentLength);
|
||||
sendUpdate(succObj, true);
|
||||
}
|
||||
catch(Exception e){
|
||||
LOG.e(LOG_TAG,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Add postMessage interface
|
||||
class JsObject {
|
||||
@@ -1006,10 +988,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
|
||||
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
|
||||
}
|
||||
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
|
||||
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
|
||||
|
||||
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
|
||||
String appendUserAgent = preferences.getString("AppendUserAgent", null);
|
||||
@@ -1018,7 +998,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
settings.setUserAgentString(overrideUserAgent);
|
||||
}
|
||||
if (appendUserAgent != null) {
|
||||
settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent);
|
||||
settings.setUserAgentString(settings.getUserAgentString() + " " + appendUserAgent);
|
||||
}
|
||||
|
||||
//Toggle whether this is enabled or not!
|
||||
@@ -1037,15 +1017,16 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
CookieManager.getInstance().removeSessionCookie();
|
||||
}
|
||||
|
||||
// Enable Thirdparty Cookies on >=Android 5.0 device
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
|
||||
}
|
||||
// Enable Thirdparty Cookies
|
||||
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
|
||||
|
||||
inAppWebView.loadUrl(url);
|
||||
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,32 +1109,14 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
* @param intent the data from android file chooser
|
||||
*/
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
// For Android >= 5.0
|
||||
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) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
return;
|
||||
}
|
||||
mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
mUploadCallbackLollipop = null;
|
||||
}
|
||||
// For Android < 5.0
|
||||
else {
|
||||
LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
|
||||
// If RequestCode or Callback is Invalid
|
||||
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == mUploadCallback) return;
|
||||
Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
|
||||
|
||||
mUploadCallback.onReceiveValue(result);
|
||||
mUploadCallback = null;
|
||||
LOG.d(LOG_TAG, "onActivityResult");
|
||||
// If RequestCode or Callback is Invalid
|
||||
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
return;
|
||||
}
|
||||
mUploadCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
mUploadCallback = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1353,28 +1316,13 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Legacy (deprecated in API 21)
|
||||
* For Android 4.4 and below.
|
||||
* @param view
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
|
||||
return shouldInterceptRequest(url, super.shouldInterceptRequest(view, url), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* New (added in API 21)
|
||||
* For Android 5.0 and above.
|
||||
*
|
||||
* @param webView
|
||||
* @param view
|
||||
* @param request
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
|
||||
@@ -1425,16 +1373,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
super.onPageFinished(view, url);
|
||||
|
||||
// Set the namespace for postMessage()
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
|
||||
}
|
||||
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 >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().flush();
|
||||
} else {
|
||||
CookieSyncManager.getInstance().sync();
|
||||
}
|
||||
CookieManager.getInstance().flush();
|
||||
|
||||
// https://issues.apache.org/jira/browse/CB-11248
|
||||
view.clearFocus();
|
||||
|
||||
@@ -24,12 +24,17 @@ 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;
|
||||
import android.webkit.GeolocationPermissions.Callback;
|
||||
import android.webkit.PermissionRequest;
|
||||
|
||||
public class InAppChromeClient extends WebChromeClient {
|
||||
|
||||
@@ -41,6 +46,13 @@ public class InAppChromeClient extends WebChromeClient {
|
||||
super();
|
||||
this.webView = webView;
|
||||
}
|
||||
|
||||
public void onPermissionRequest(final PermissionRequest request) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
request.grant(request.getResources());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle database quota exceeded notification.
|
||||
*
|
||||
@@ -135,4 +147,44 @@ 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() {
|
||||
@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,43 +17,37 @@
|
||||
* 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
|
||||
}
|
||||
});
|
||||
|
||||
@@ -153,7 +147,9 @@ var IAB = {
|
||||
|
||||
backButton.innerHTML = '←';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) { popup.goBack(); }
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
}
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('button');
|
||||
@@ -164,7 +160,9 @@ var IAB = {
|
||||
|
||||
forwardButton.innerHTML = '→';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) { popup.goForward(); }
|
||||
if (popup.canGoForward) {
|
||||
popup.goForward();
|
||||
}
|
||||
});
|
||||
|
||||
closeButton = document.createElement('button');
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler>{
|
||||
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler,UIAdaptivePresentationControllerDelegate>{
|
||||
@private
|
||||
CDVInAppBrowserOptions *_browserOptions;
|
||||
NSDictionary *_settings;
|
||||
|
||||
@@ -18,9 +18,12 @@
|
||||
*/
|
||||
|
||||
#import "CDVWKInAppBrowser.h"
|
||||
#import <Cordova/NSDictionary+CordovaPreferences.h>
|
||||
|
||||
#if __has_include("CDVWKProcessPoolFactory.h")
|
||||
#import "CDVWKProcessPoolFactory.h"
|
||||
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>) // Cordova-iOS >=6
|
||||
#import <Cordova/CDVWebViewProcessPoolFactory.h>
|
||||
#elif __has_include("CDVWKProcessPoolFactory.h") // Cordova-iOS <6 with WKWebView plugin
|
||||
#import "CDVWKProcessPoolFactory.h"
|
||||
#endif
|
||||
|
||||
#import <Cordova/CDVPluginResult.h>
|
||||
@@ -290,6 +293,7 @@ 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;
|
||||
|
||||
@@ -306,7 +310,6 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
|
||||
}
|
||||
UIViewController *tmpController = [[UIViewController alloc] init];
|
||||
|
||||
[strongSelf->tmpWindow setRootViewController:tmpController];
|
||||
[strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal];
|
||||
|
||||
@@ -537,8 +540,9 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
}
|
||||
|
||||
//if is an app store link, let the system handle it, otherwise it fails to load it
|
||||
if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {
|
||||
//if is an app store, tel, sms, mailto or geo link, let the system handle it, otherwise it fails to load it
|
||||
NSArray * allowedSchemes = @[@"itms-appss", @"itms-apps", @"tel", @"sms", @"mailto", @"geo"];
|
||||
if ([allowedSchemes containsObject:[url scheme]]) {
|
||||
[theWebView stopLoading];
|
||||
[self openInSystem:url];
|
||||
shouldStart = NO;
|
||||
@@ -739,7 +743,9 @@ BOOL isExiting = FALSE;
|
||||
}
|
||||
configuration.applicationNameForUserAgent = userAgent;
|
||||
configuration.userContentController = userContentController;
|
||||
#if __has_include("CDVWKProcessPoolFactory.h")
|
||||
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>)
|
||||
configuration.processPool = [[CDVWebViewProcessPoolFactory sharedFactory] sharedProcessPool];
|
||||
#elif __has_include("CDVWKProcessPoolFactory.h")
|
||||
configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
|
||||
#endif
|
||||
[configuration.userContentController addScriptMessageHandler:self name:IAB_BRIDGE_NAME];
|
||||
@@ -757,9 +763,33 @@ 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];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400
|
||||
// With the introduction of iOS 16.4 the webview is no longer inspectable by default.
|
||||
// We'll honor that change for release builds, but will still allow inspection on debug builds by default.
|
||||
// We also introduce an override option, so consumers can influence this decision in their own build.
|
||||
if (@available(iOS 16.4, *)) {
|
||||
#ifdef DEBUG
|
||||
BOOL allowWebviewInspectionDefault = YES;
|
||||
#else
|
||||
BOOL allowWebviewInspectionDefault = NO;
|
||||
#endif
|
||||
self.webView.inspectable = [_settings cordovaBoolSettingForKey:@"InspectableWebview" defaultValue:allowWebviewInspectionDefault];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
[self.view addSubview:self.webView];
|
||||
[self.view sendSubviewToBack:self.webView];
|
||||
@@ -1055,7 +1085,18 @@ BOOL isExiting = FALSE;
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
return UIStatusBarStyleDefault;
|
||||
NSString* statusBarStylePreference = [self settingForKey:@"InAppBrowserStatusBarStyle"];
|
||||
if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"lightcontent"]) {
|
||||
return UIStatusBarStyleLightContent;
|
||||
} else if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"darkcontent"]) {
|
||||
if (@available(iOS 13.0, *)) {
|
||||
return UIStatusBarStyleDarkContent;
|
||||
} else {
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
} else {
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
@@ -1071,6 +1112,7 @@ 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 {
|
||||
@@ -1257,5 +1299,10 @@ BOOL isExiting = FALSE;
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
}
|
||||
|
||||
#pragma mark UIAdaptivePresentationControllerDelegate
|
||||
|
||||
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController {
|
||||
isExiting = TRUE;
|
||||
}
|
||||
|
||||
@end //CDVWKInAppBrowserViewController
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
/* jslint sloppy:true */
|
||||
/* global Windows:true, setImmediate */
|
||||
/* eslint standard/no-callback-literal : 0 */
|
||||
/* eslint-disable standard/no-callback-literal */
|
||||
/* global Windows, setImmediate */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
@@ -44,21 +43,32 @@ 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) {
|
||||
@@ -78,15 +88,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);
|
||||
@@ -175,7 +185,8 @@ 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';
|
||||
@@ -240,14 +251,18 @@ 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');
|
||||
@@ -292,11 +307,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();
|
||||
}
|
||||
});
|
||||
@@ -323,7 +338,7 @@ var IAB = {
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
});
|
||||
});
|
||||
@@ -352,13 +367,18 @@ 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
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -367,8 +387,10 @@ 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 () {
|
||||
@@ -376,7 +398,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.0.0",
|
||||
"version": "5.1.0-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser-tests",
|
||||
|
||||
+1
-8
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="4.0.0">
|
||||
version="5.1.0-dev">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
@@ -29,12 +29,5 @@
|
||||
<js-module src="tests.js" name="tests">
|
||||
</js-module>
|
||||
|
||||
<platform name="ios">
|
||||
<!-- The WKWebView implementation for inappbrowser requires the presence of this plugin -->
|
||||
<dependency id="cordova-plugin-wkwebview-engine" />
|
||||
<dependency id="cordova-plugin-wkwebview-engine-allowfileaccess" url="https://github.com/knight9999/cordova-plugin-wkwebview-engine-allowfileaccess.git" />
|
||||
</platform>
|
||||
|
||||
|
||||
<asset src="resources" target="cdvtests/iab-resources" />
|
||||
</plugin>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* 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';
|
||||
|
||||
+523
-244
@@ -17,7 +17,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
/* global MSApp */
|
||||
|
||||
@@ -38,7 +38,6 @@ exports.defineAutoTests = function () {
|
||||
platformOpts = platformOpts || '';
|
||||
|
||||
describe('cordova.InAppBrowser', function () {
|
||||
|
||||
it('inappbrowser.spec.1 should exist', function () {
|
||||
expect(cordova.InAppBrowser).toBeDefined();
|
||||
});
|
||||
@@ -50,7 +49,6 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
describe('open method', function () {
|
||||
|
||||
if (cordova.platformId === 'osx') {
|
||||
pending('Open method not fully supported on OSX.');
|
||||
return;
|
||||
@@ -62,7 +60,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;
|
||||
|
||||
@@ -70,7 +68,7 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
// restore original timeout
|
||||
// restore original timeout
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
|
||||
if (iabInstance !== null && iabInstance.close) {
|
||||
@@ -122,8 +120,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();
|
||||
@@ -144,9 +142,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) {
|
||||
@@ -157,7 +155,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';
|
||||
@@ -172,13 +170,17 @@ 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 });
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -186,7 +188,6 @@ exports.defineAutoTests = function () {
|
||||
};
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
var platformOpts = '';
|
||||
var platform_info = '';
|
||||
|
||||
@@ -200,10 +201,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 = '';
|
||||
}
|
||||
@@ -243,15 +244,20 @@ 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;
|
||||
@@ -273,7 +279,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
function doHookOpen (url, target, params, numExpectedRedirects) {
|
||||
var originalFunc = window.open;
|
||||
var wasClobbered = window.hasOwnProperty('open');
|
||||
var wasClobbered = Object.prototype.hasOwnProperty.call(window, 'open');
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
try {
|
||||
@@ -295,7 +301,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) {
|
||||
@@ -304,8 +310,7 @@ 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -314,37 +319,48 @@ 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;
|
||||
}
|
||||
@@ -368,7 +384,8 @@ 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>' +
|
||||
@@ -376,7 +393,8 @@ 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>' +
|
||||
@@ -396,7 +414,8 @@ 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>' +
|
||||
@@ -412,7 +431,8 @@ 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>' +
|
||||
@@ -428,19 +448,22 @@ 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>' +
|
||||
@@ -448,7 +471,8 @@ 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>' +
|
||||
@@ -468,7 +492,8 @@ 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>' +
|
||||
@@ -480,13 +505,15 @@ 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>' +
|
||||
@@ -494,13 +521,15 @@ 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>' +
|
||||
@@ -514,12 +543,38 @@ 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;
|
||||
@@ -534,206 +589,430 @@ 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('https://cordova.apache.org');
|
||||
},
|
||||
'openWhiteListed'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=Default (window.open)',
|
||||
function () {
|
||||
doHookOpen('https://cordova.apache.org');
|
||||
},
|
||||
'openWhiteListedHook'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=_self',
|
||||
function () {
|
||||
doOpen('https://cordova.apache.org', '_self');
|
||||
},
|
||||
'openWhiteListedSelf'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_system',
|
||||
function () {
|
||||
doOpen('https://cordova.apache.org', '_system');
|
||||
},
|
||||
'openWhiteListedSystem'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_blank',
|
||||
function () {
|
||||
doOpen('https://cordova.apache.org', '_blank');
|
||||
},
|
||||
'openWhiteListedBlank'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random',
|
||||
function () {
|
||||
doOpen('https://cordova.apache.org', 'random_string');
|
||||
},
|
||||
'openWhiteListedRandom'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=Random, no location bar',
|
||||
function () {
|
||||
doOpen('https://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('https://www.apple.com');
|
||||
},
|
||||
'openNonWhiteListed'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Default (window.open)',
|
||||
function () {
|
||||
doHookOpen('https://www.apple.com');
|
||||
},
|
||||
'openNonWhiteListedHook'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_self',
|
||||
function () {
|
||||
doOpen('https://www.apple.com', '_self');
|
||||
},
|
||||
'openNonWhiteListedSelf'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_system',
|
||||
function () {
|
||||
doOpen('https://www.apple.com', '_system');
|
||||
},
|
||||
'openNonWhiteListedSystem'
|
||||
);
|
||||
createActionButton(
|
||||
'target=_blank',
|
||||
function () {
|
||||
doOpen('https://www.apple.com', '_blank');
|
||||
},
|
||||
'openNonWhiteListedBlank'
|
||||
);
|
||||
createActionButton(
|
||||
'target=Random',
|
||||
function () {
|
||||
doOpen('https://www.apple.com', 'random_string');
|
||||
},
|
||||
'openNonWhiteListedRandom'
|
||||
);
|
||||
createActionButton(
|
||||
'* target=Random, no location bar',
|
||||
function () {
|
||||
doOpen('https://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('https://google.co.uk', 'random_string', '', 1);
|
||||
},
|
||||
'openRedirect301'
|
||||
);
|
||||
createActionButton(
|
||||
'http://goo.gl/pUFqg',
|
||||
function () {
|
||||
doOpen('https://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('https://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('https://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();
|
||||
});
|
||||
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();
|
||||
createActionButton(
|
||||
'no hardwareback (defaults to yes)',
|
||||
function () {
|
||||
doOpen('https://cordova.apache.org', '_blank');
|
||||
},
|
||||
'openHardwareBackDefault'
|
||||
);
|
||||
createActionButton(
|
||||
'hardwareback=yes',
|
||||
function () {
|
||||
doOpen('https://cordova.apache.org', '_blank', 'hardwareback=yes');
|
||||
},
|
||||
'openHardwareBackYes'
|
||||
);
|
||||
createActionButton(
|
||||
'hardwareback=no',
|
||||
function () {
|
||||
doOpen('https://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();
|
||||
});
|
||||
ref2.addEventListener('exit', function () {
|
||||
cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
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 : ''));
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 'openHardwareBackDefaultAfterNo');
|
||||
},
|
||||
'openHardwareBackDefaultAfterNo'
|
||||
);
|
||||
};
|
||||
|
||||
Vendored
+6
-7
@@ -8,7 +8,12 @@
|
||||
// TypeScript Version: 2.3
|
||||
type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message" | "customscheme";
|
||||
|
||||
interface Window {
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
@@ -18,13 +23,7 @@ interface Window {
|
||||
* 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;
|
||||
|
||||
+14
-9
@@ -17,7 +17,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var exec = require('cordova/exec');
|
||||
@@ -27,19 +27,20 @@
|
||||
|
||||
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'),
|
||||
download: channel.create('download')
|
||||
};
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -89,6 +90,10 @@
|
||||
} else {
|
||||
throw new Error('insertCSS requires exactly one of code or file to be specified');
|
||||
}
|
||||
},
|
||||
|
||||
addDownloadListener: function (success, error) {
|
||||
exec(success, error, 'InAppBrowser', 'downloadListener');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user