-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ios): allow changing WebView read access when loading local file (#…
…11431) Co-authored-by: Lokesh Choudhary <lchoudhary@axway.com> Fixes TIMOB-27159
- Loading branch information
1 parent
eef37a6
commit dd7b319
Showing
6 changed files
with
142 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title> | ||
Title | ||
</title> | ||
<script type="text/javascript"> | ||
window.onload = function() { | ||
window.location.href="../folder with spaces/comingSoon.html" | ||
}; | ||
</script> | ||
</head> | ||
|
||
<h1> Test HTML </h1> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
/* eslint-env mocha */ | ||
/* eslint no-unused-expressions: "off" */ | ||
'use strict'; | ||
var should = require('./utilities/assertions'), | ||
utilities = require('./utilities/utilities'); | ||
|
||
describe('Titanium.UI.WebView', function () { | ||
var win; | ||
this.slow(3000); | ||
this.timeout(30000); | ||
|
||
afterEach(function (done) { | ||
if (win) { | ||
// If `win` is already closed, we're done. | ||
let t = setTimeout(function () { | ||
if (win) { | ||
win = null; | ||
done(); | ||
} | ||
}, 3000); | ||
|
||
win.addEventListener('close', function listener () { | ||
clearTimeout(t); | ||
|
||
if (win) { | ||
win.removeEventListener('close', listener); | ||
} | ||
win = null; | ||
done(); | ||
}); | ||
win.close(); | ||
} else { | ||
win = null; | ||
done(); | ||
} | ||
}); | ||
|
||
it.ios('#assetsDirectory', function (finish) { | ||
win = Ti.UI.createWindow(); | ||
var loadCount = 0; | ||
function createDirectory(f) { | ||
if (f && !f.exists()) { | ||
f.createDirectory(); | ||
} | ||
return f; | ||
} | ||
|
||
// Copy from Resources to cache folder | ||
var cacheDir = createDirectory(Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory)); | ||
createDirectory(Ti.Filesystem.getFile(cacheDir.nativePath, 'html')); | ||
createDirectory(Ti.Filesystem.getFile(cacheDir.nativePath, 'folder with spaces')); | ||
|
||
var htmlFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'html', 'example.html'); | ||
var nextHtmlFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'folder with spaces', 'comingSoon.html'); | ||
|
||
var htmlInCache = Ti.Filesystem.getFile(cacheDir.nativePath, 'html', 'example.html'); | ||
var nextHtmlInCache = Ti.Filesystem.getFile(cacheDir.nativePath, 'folder with spaces', 'comingSoon.html'); | ||
|
||
htmlFile.copy(htmlInCache.nativePath); | ||
nextHtmlFile.copy(nextHtmlInCache.nativePath); | ||
|
||
var webView = Ti.UI.createWebView({ | ||
width: Ti.UI.FILL, | ||
height: Ti.UI.FILL, | ||
url: htmlInCache.nativePath, | ||
assetsDirectory: cacheDir.nativePath | ||
}); | ||
|
||
webView.addEventListener('load', function () { | ||
loadCount++; | ||
if (loadCount > 1) { | ||
finish(); | ||
} | ||
}); | ||
win.add(webView); | ||
win.open(); | ||
}); | ||
|
||
}); |