summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2015-06-26 12:15:16 -0700
committerPhilip Chimento <philip@endlessm.com>2015-06-26 17:45:05 -0700
commit3599cb4c011597a2cfdfd7ca652ab79edab24be2 (patch)
tree38121dc910c62af44298494a2ce2e57a94af184b /test
parent2d93813e4577c2f7a61fd6f0be3824cdee6efca4 (diff)
Webhelper local:// URI scheme
This adds a local:// URI scheme available to applications using WebHelper which behaves just like the file:// URI scheme only with fewer security restrictions. [endlessm/eos-shell#2309]
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am.inc1
-rw-r--r--test/webhelper/testLocal.js59
2 files changed, 60 insertions, 0 deletions
diff --git a/test/Makefile.am.inc b/test/Makefile.am.inc
index f541a5b..d927da8 100644
--- a/test/Makefile.am.inc
+++ b/test/Makefile.am.inc
@@ -44,6 +44,7 @@ EXTRA_DIST += \
javascript_tests = \
test/tools/eos-application-manifest/testInit.js \
test/tools/testHtmlExtractor.js \
+ test/webhelper/testLocal.js \
test/webhelper/testTranslate.js \
test/webhelper/testTranslate2.js \
test/webhelper/testWebActions.js \
diff --git a/test/webhelper/testLocal.js b/test/webhelper/testLocal.js
new file mode 100644
index 0000000..d65e6c7
--- /dev/null
+++ b/test/webhelper/testLocal.js
@@ -0,0 +1,59 @@
+// Copyright 2015 Endless Mobile, Inc.
+
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
+const WebHelper2 = imports.webhelper2;
+const WebKit2 = imports.gi.WebKit2;
+
+const WELL_KNOWN_NAME = 'com.endlessm.WebHelper.testLocal';
+
+Gtk.init(null);
+
+describe('Local URI scheme', function () {
+ let owner_id, connection, webview, webhelper;
+
+ beforeAll(function (done) {
+ owner_id = Gio.DBus.own_name(Gio.BusType.SESSION, WELL_KNOWN_NAME,
+ Gio.BusNameOwnerFlags.NONE,
+ null, // bus acquired
+ (con, name) => { // name acquired
+ connection = con;
+ done();
+ },
+ null); // name lost
+ });
+
+ afterAll(function () {
+ Gio.DBus.unown_name(owner_id);
+ });
+
+ beforeEach(function () {
+ webhelper = new WebHelper2.WebHelper({
+ well_known_name: WELL_KNOWN_NAME,
+ connection: connection,
+ });
+ webview = new WebKit2.WebView();
+ });
+
+ afterEach(function () {
+ webhelper.unregister();
+ });
+
+ it('loads a local file', function (done) {
+ let path = GLib.build_filenamev([GLib.getenv('TOP_SRCDIR'), 'test',
+ 'tools', 'test.html']);
+ let test_file = Gio.File.new_for_path(path);
+
+ let error_spy = jasmine.createSpy('error_spy');
+ webview.connect('load-failed', error_spy);
+ let id = webview.connect('load-changed', (webview, event) => {
+ if (event === WebKit2.LoadEvent.FINISHED) {
+ webview.disconnect(id);
+ expect(error_spy).not.toHaveBeenCalled();
+ done();
+ }
+ });
+ webview.load_uri(test_file.get_uri().replace(/^file:/, 'local:'));
+ });
+});