SECURITY_ERR: DOM Exception 18 on iOS 5.1 when upgrading app with WebView that opens local database - ios

If you build a simple Titanium mobile application that contains a WebView which has in it javascript that opens a local database, the first time you install it to an iOS 5.1 device it will open the database correctly. However, if you then upgrade the app on the device (it can still be the exact same version/build), it will error when opening the local database:
SECURITY_ERR: DOM Exception 18
Steps to reproduce:
Add the app.js and database.html files below to the root of Resources.
Install app to iOS 5.1 device (Run > iOS Device in Ti Studio).
Open app, it will say "db opened".
Upgrade app on iOS 5.1 device (Run > iOS Device in Ti Studio).
Open app, it will say "db opening failed: Error: SECURITY_ERR: DOM Exception 18".
Here is the code to reproduce:
app.js:
var win = Ti.UI.createWindow({});
var webView = Ti.UI.createWebView({
top : 0, right : 0, bottom : 0, left : 0, url: 'database.html'
});
win.add(webView);
win.open();
database.html:
<!DOCTYPE HTML>
<html>
<head>
<title>db test</title>
<script>
window.onload = function () {
var dbConn;
try {
dbConn = openDatabase('test', '0.1', 'test database', 5 * 1024 * 1024);
alert('db opened');
} catch (e) {
alert('db opening failed: ' + e.toString());
}
};
</script>
</head>
<body>
db test
</body>
</html>
This issue seems to be the same as Apache Cordova has had and fixed.
https://issues.apache.org/jira/browse/CB-347
Has anyone else run into this issue? Any ideas for a work-around?

We ended up creating a custom webview module for iOS to fix the issue ourselves, as who knows how long it'll take before Titanium does the same:
Webview Module Source

Related

Lost Microsoft Edge (Chromium) IE Mode showModalDialog zoom level

Legacy Web application support. This is a use case when End-users access the Site from the 'Remote Desktop Connection'.
On Microsoft Windows (Server 2016/ 2019) versions the Microsoft's legacy feature showModalDialog zoom-level screen.deviceXDPI appears to be lost, meaning zoom is reset to default ctrl+0 zoom-level.
According to Microsoft the expected behavior would be that zoom-level is preserved
[ Reference: https://learn.microsoft.com/en-us/troubleshoot/developer/browsers/core-features/new-window-not-respect-zoom-level, Date 20.10.2022]
In Internet Explorer 9 and later versions, windows created using the window.open API (as well as showMod[al:eless]Dialog and createPopup) have been designed to not honor the Reset zoom level for new windows and tabs setting and always inherit the zoom factor from their parent page.
I have not been able to trace this behavior to specific Microsoft Edge, Internet Options setting. No error message found. The issue is not present in IE11.
Setup
Verified on Microsoft Edge Version 106.0.1370.47 (Official build) (64-bit) - Issue is present already for several versions, since discovered earlier this year when migrating away from IE11
Microsoft Edge with IE mode. IE mode enables backward compatibility to Enterprise support
<site url="localhost/SiteName">
<compat-mode>IE8Enterprise</compat-mode>
<open-in>IE11</open-in>
</site>
Opener and modal window has the same host, port and http scheme.
Both http or https are verified, both localhost or domain verified
Site is added to Trusted Sites
Site is not in Compatibility view Settings Websites list
Protected mode not enabled for Trusted sites (not ticked)
The Server's Browser is accessed from 'Remote Desktop Connection'
Works with versions tested: Windows 10 (1909) - two instances verified, Windows Server 2012 R2 (9600)
Not Working Windows Server 2019 (1809) - two instances verified, Windows Server 2016 (1607)
What has been tried
Internet Options, Advanced - Restore and Advanced - Restore Advanced Settings
Microsoft Edge Reset Settings - Restore settings to their default values
Internet Options, Advanced 'Reset zoom level for new windows and tabs' (not ticked). Seems to have no effect if ticked
Reinstall Edge
Changing Zoom related Registries seems to have no effect on Edge IE Mode, Registries under
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom
or
Computer\HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Zoom
Verified issue with different resolution monitors that, the same if zoom ctrl+0 is 100% or 200%
Reproduction html Opener html (Note: ZoomLevel scale not converted to percentage here)
<!doctype html>
<html>
<head>
<title>Open Modal Dialog Test</title>
<script type="text/javascript">
function ready(callback) {
document.attachEvent('onreadystatechange', function () {
if (document.readyState == 'complete') callback();
});
}
ready(function () {
var zoomLevel = screen.deviceXDPI / screen.logicalXDPI;
document.getElementById("zoomLevel").innerHTML = zoomLevel;
document.getElementById("deviceXDPI").innerHTML = screen.deviceXDPI;
document.getElementById("logicalXDPI").innerHTML = screen.logicalXDPI;
document.getElementById("systemXDPI").innerHTML = screen.systemXDPI;
var ls_arguments = { zoomLevel: zoomLevel };
var url = "modalDialog2.htm?v=" + new Date();
window.showModalDialog(url, ls_arguments, "center:yes;dialogWidth:600px;dialogHeight:300px;status:yes;resizable=yes");
});
</script>
</head>
<body>
Sample text
Opener zoom: <div id="zoomLevel"></div>
<p>deviceXDPI: <span id="deviceXDPI"></span></p>
<p>logicalXDPI: <span id="logicalXDPI"></span></p>
<p>systemXDPI: <span id="systemXDPI"></span></p>
</body>
</html>
Modal html
<!doctype html>
<html>
<head>
<title>Modal Dialog</title>
<script type="text/javascript">
function ready(callback) {
document.attachEvent('onreadystatechange', function () {
if (document.readyState == 'complete') callback();
});
}
ready(function () {
document.getElementById("zoomLevel").innerHTML = screen.deviceXDPI / screen.logicalXDPI;
document.getElementById("zoomLevelParent").innerHTML = window.dialogArguments.zoomLevel;
document.getElementById("deviceXDPI").innerHTML = screen.deviceXDPI;
document.getElementById("logicalXDPI").innerHTML = screen.logicalXDPI;
document.getElementById("systemXDPI").innerHTML = screen.systemXDPI;
});
</script>
</head>
<body>
Sample text
<p>Modal zoom: <span id="zoomLevel"></span></p>
<p>Opener zoom: <span id="zoomLevelParent"></span></p>
<p>deviceXDPI: <span id="deviceXDPI"></span></p>
<p>logicalXDPI: <span id="logicalXDPI"></span></p>
<p>systemXDPI: <span id="systemXDPI"></span></p>
</body>
</html>
Example #1 Server 2019
Opener Zoom 250% (status bar) (Edge shows zoom 150%)
deviceXDPI: 240
logicalXDPI: 96
systemXDPI: 192
Modal Dialog zoom
deviceXDPI: 192
logicalXDPI: 96
systemXDPI: 192
Expected would be that deviceXDPI for Modal zoom window would be 240
Example #2 Server 2016 Screenshot from example code
Expected that deviceXDPI for Modal window would be 77 same as for opener.
Expected the same behavior if tested on IE11 Enterprise mode on the same machine

our angular application isn't working from IOS 15 (Safari) , it works for older versions of safari and other browsers

Application is not loading in safari 15 and higher versions, there are no console errors.
In chrome our application is being detected as angular application and the component is loaded as Angular widget component here
Where as in safari it is loaded as
Screenshots attached.
Source code:
<script>
var angWidgets = 'unauthenticated';
var cId = '#ViewBag.ClientId';
</script>
#{string angWidgetsHtml = "<unauthenticated></unauthenticated>";}
<app></app>
<script>
var angWidgetsHtml = "#Html.Raw(angWidgetsHtml)";
</script>
Inspect source code image in Safari
Inspect source code image in chrome

Converting Web app into Desktop app with Electron

Hey i am web developer and i wanted to make app for desktop. I discovered program named Electron i downloaded it from this page: electron.atom.io
Next I created files that are needed for running this app:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
</html>
Then main.js:
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
function createWindow () {
// Create the browser window.
win = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
// Open the DevTools.
win.webContents.openDevTools()
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
and package.json:
{
"name" : "Test-App",
"version" : "0.1.0",
"main" : "main.js"
}
Now when i type in CMD
Electron .
i get the error
'electron' is not recognized as an internal or external command,
operable program or batch file.
Is there any way to run this program from app installed without CMD or How can i fix this?
Welcome to stackoverflow!
The package you installed is a demo package that is meant to demonstrate the different features Electron offers to developers. It is not suitable for your needs right now.
What you need instead is, as devilfart and Vadim pointed out, a global installation of the Electron runtime. This can be achieved by starting a command line with administrative rights and entering the following command:
npm install -g electron
This will install the Electron runtime as a global package inside your base node_modules directory and enable the use of the electron command.

MobileFirst Platform adapter invocation fails in simulator

I have a sample project "Invoking adapter Procedures" in MobileFirst Platform. It receives feed and shows value while previewing in the MFP Console, but after adding the iPad environment and running it in Xcode it does not fetch any feed and instead shows an error in the Xcode console:
Cannot fetch feed
and in the iOS Simulator:
service not available
Adapter code
<displayName>RSSReader</displayName>
<description>RSSReader</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>rss.cnn.com</domain>
<port>80</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
</connectivity>
<procedure name="getFeeds"/>
<procedure name="getFeedsFiltered"/>
JS Code
var busyIndicator = null;
function wlCommonInit(){
busyIndicator = new WL.BusyIndicator();
loadFeeds();
}
function loadFeeds(){
busyIndicator.show();
/*
* The REST API works with all adapters and external resources, and is supported on the following hybrid environments:
* iOS, Android, Windows Phone 8, Windows 8.
* If your application supports other hybrid environments, see the tutorial for MobileFirst 6.3.
*/
var resourceRequest = new WLResourceRequest("/adapters/RSSReader/getFeedsFiltered", WLResourceRequest.GET);
resourceRequest.setQueryParameter("params", "['technology']");
resourceRequest.send().then(
loadFeedsSuccess,
loadFeedsFailure
);
}
function loadFeedsSuccess(result){
WL.Logger.debug("Feed retrieve success");
busyIndicator.hide();
if (result.responseJSON.Items.length>0)
displayFeeds(result.responseJSON.Items);
else
loadFeedsFailure();
}
function loadFeedsFailure(result){
WL.Logger.error("Feed retrieve failure");
busyIndicator.hide();
WL.SimpleDialog.show("Engadget Reader", "Service not available. Try again later.",
[{
text : 'Reload',
handler : WL.Client.reloadApp
},
{
text: 'Close',
handler : function() {}
}]
);
}
function displayFeeds(items){
var ul = $('#itemsList');
for (var i = 0; i < items.length; i++) {
var li = $('<li/>').text(items[i].title);
var pubDate = $('<div/>', {
'class': 'pubDate'
}).text(items[i].pubDate);
li.append(pubDate);
ul.append(li);
}
Xcode Console log
I had used the code give in the sample app.
I am unable to recreate this error.
Make sure these are the steps you've taken:
Import into MobileFirst Platform Studio 7.0 the "Invoking adapter procedures in hybrid applications" sample project
Right-click on the adapter folder and select Run As > Deploy MobileFirst Adapter
Right-click on the project folder and select New > MobileFirst Environment, add iPad environment
Right-click on the iPad folder and select Run As > Xcode project
Click Run in Xcode
For me, by following the above steps I was able to successfully run the sample application in the iOS Simulator = the app was displayed and feeds were retrieved.

Invoke native file browser using phonegap

I have to implement file upload feature in my phonegap project. User should be able to upload any type of file from the phone memory or sd card. The application screens I designed using jQuery Mobile framework. I tried input type="file", but it is not supported in android 4.4. I tried phonegap camera API too, but it is supported only media files. I found some cordova plugins (exm1,exm2 ). But these plugins using custom UI. I want to invoke native file browser for choosing the file & it has to work in both Android & iPhone platforms. Is there a way to implement the same?
I found cordova file chooser plugin (https://github.com/cdibened/filechooser) would be helpful for android platform, but I am unable to make it work. The success callback function is not immediately getting triggered after the file selection (tested with android 4.4.2). Please find my code below,
<input type="file" id="fileinput" name="fileinput"/>
$("#fileinput").bind('click',function(){
console.log("choose file selected");
filechooser.open( {}, fileChooseSuccess, fileChooseFailed );
});
function fileChooseSuccess(data) {
var filepath = data.filepath;
console.log("file path:"+filepath);
}
function fileChooseFailed(msg) {
console.log(msg);
}
I was able to get your plugin, FileChooser working.
There are certain things that have to be done though.
You need to open the following with your editor
FileChooser.java
FileChooserActivity.java
FileListAdapter.java
FileListFragment.java
LocalStorageProvider.java
and append
import your.package.name.R;
to each of those files.
Here is the demo code I used:
<html>
<head>
<title>Hello World</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", function(){
var success = function(data) {
alert("File chosen: " + data.filepath);
};
var error = function(msg) {
console.log( msg );
};
$('#fileinput').click(function(e) {
filechooser.open({}, success,error);
});
});
</script>
</head>
<body>
<input type="file" id="fileinput" name="fileinput"/>
</body>
</html>
Also, be aware that the author intended this to be used in KitKat 4.4.4. It may work with lower versions but he's uncertain.
Take note that the only difference between the HTML5 choice window and this is the "Internal Storage" option.
Hope this helps.
For android you can use this plugin:
https://github.com/cdibened/filechooser
input file should work on android too (on most of the versions, but it doesn't work on android 4.4, 4.4.1 and 4.4.2)
HTML file input in android webview (android 4.4, kitkat)
for iOS there is no plugin, you don't have a native file browser.
Sample project
https://github.com/jcesarmobile/FileBrowserAndroidTest

Resources