Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 preview #94

Merged
merged 44 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2501c88
add object.assign polyfill and skip tests ctx
Mar 17, 2017
83bd4ea
updated bower
Sep 1, 2016
5a3242a
bower update
Sep 13, 2016
5bb35ac
fixed bower and a small test issue (#65)
e111077 Sep 13, 2016
ec46dd0
bower major version bump
Sep 17, 2016
8bbff12
Set dev dependencies to 2.0-preview branches.
cdata Nov 17, 2016
4579e7f
Move promise-polyfill to dependencies.
cdata Nov 17, 2016
200bdba
bower update
Dec 8, 2016
0adfa9b
test proper things
Dec 8, 2016
3b928c8
moved promise polyfill to dev
Dec 8, 2016
d73f625
Depend on test-fixture v2 (#85)
e111077 Jan 12, 2017
363903c
auto-generated: update repo for v2
tedium-bot Jan 25, 2017
1642211
Sort dependencies.
bicknellr Mar 1, 2017
9423a72
Update dependencies.
bicknellr Mar 1, 2017
5bad126
add travis config
dfreedm Mar 6, 2017
2f6ceb2
forcing travis
Mar 6, 2017
a7f7f2f
added promise polyfill to test compat suite
Mar 6, 2017
4be7542
fixed bower resolutions
Mar 8, 2017
4956448
deleted extraneous file
Mar 8, 2017
4e939f6
added promise polyfill
Mar 8, 2017
3a790b6
ignore variants bower
Mar 8, 2017
2c44acd
add promise polyfill
Mar 8, 2017
b32ecaf
fix promise polyfill html import
Mar 8, 2017
18fc47c
fix currentScript baseURI
Mar 8, 2017
cec14e7
ie worker event workaround
Mar 8, 2017
2e392ed
removed indexeddb tests for IE
Mar 14, 2017
be76a22
prevent thrown exceptions in unsupported browsers
Mar 14, 2017
8f3f5b5
defer the connect event
Mar 15, 2017
06214f1
conditional tests via proper feature detection
Mar 16, 2017
7ffb44d
skip mocha tests instead of conditional loading
Mar 16, 2017
118a4ea
forcing newest version of WCT
Mar 16, 2017
cf180f0
feature detect supports Safari
Mar 16, 2017
a7fa4f0
remove IE / Edge workaround
Mar 16, 2017
4ba52a8
binding to a fail timeout
Mar 16, 2017
8e448fc
WC ready listener is blocking
Mar 24, 2017
53c4b83
update polymer to rc 3
Mar 31, 2017
7833579
Update travis config
tedium-bot Apr 7, 2017
1902862
code makes more sense got rid ifs
Apr 7, 2017
036e5b8
nittiest nit of nittington
Apr 11, 2017
efeafd8
awkward, I literally didn't remove the line in the last commit
Apr 11, 2017
094db6c
fixed polymer dep to use ^
Apr 14, 2017
cc4798c
Update README.md
e111077 Apr 19, 2017
6d8eb79
fixes #105
Apr 27, 2017
7669111
Update .travis.yml
e111077 May 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bower_components
bower_components*
node_modules
bower-*.json
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dist: trusty
language: node_js
sudo: required
node_js: stable
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
before_script:
- npm install -g polymer-cli
- polymer install --variants
script:
- xvfb-run polymer test
- >-
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then polymer test -s 'default';
fi
env:
global:
- secure: >-
I6aEZebEmxr9TOJnN1i45lUb0EGeAgVdv4YbwDy3NkRotWEFVWIkLzfJaKh6RqNh6u8RUiOS4OaJznmJ6B6TlUvwxyLFKbNYmc9+7o5MjFIBv7Gr4WdXMZruPu1K08lCVupiAuuJNg9HB7FlxhLI8N0STz/1bZS/aJ6AugHp8qZaEyi9WtvW+aJEVyuS13mrLVEqUNkGOFvmjkrh7fvsSR1wgNmdhFjQKSxyDuLRM3Xe1WJN3vdfvBbk7VMp3ahttVqheFxhtumycHS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LgHqwz35/GCnHZTImMx0Pfd4=
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ The bot does some handling of markdown. Please file a bug if it does the wrong
thing! https://github.com/PolymerLabs/tedium/issues

-->
![status](https://travis-ci.org/PolymerElements/app-storage.svg?branch=2.0-preview)
## Changes in 2.0
* Promise polyfill is no longer shipped with the element. It is now a dev dependency.


##Polymer.AppStorageBehavior
## Polymer.AppStorageBehavior

AppStorageBehavior is an abstract behavior that makes it easy to
synchronize in-memory data and a persistant storage system, such as
Expand All @@ -26,7 +28,7 @@ elements see `<app-localstorage-document>` here, or check out



##&lt;app-indexeddb-mirror&gt;
## &lt;app-indexeddb-mirror&gt;

`app-indexeddb-mirror` is a purpose-built element to easily add read-only
offline access of application data that is typically only available when the
Expand Down Expand Up @@ -139,7 +141,7 @@ be available through this element.



##&lt;app-localstorage-document&gt;
## &lt;app-localstorage-document&gt;

app-localstorage-document synchronizes storage between an in-memory
value and a location in the browser's localStorage system.
Expand Down Expand Up @@ -168,7 +170,7 @@ Only supports storing JSON-serializable values.



##Polymer.AppNetworkStatusBehavior
## Polymer.AppNetworkStatusBehavior

`Polymer.AppNetworkStatusBehavior` tracks the status of whether the browser
is online or offline. True if the browser is online, and false if the browser is
Expand Down
14 changes: 10 additions & 4 deletions app-indexeddb-mirror/app-indexeddb-mirror-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@
// Maybe useful in case we want to notify clients of changes..
this[CLIENT_PORTS] = new Array;
this[DB_OPENS] = null;
this.supportsIndexedDB = self.indexedDB != null;
if (!self.Promise || !this.supportsIndexedDB) {
console.error('Indexeddb Mirror is not supported');
}

this.openDb();

self.addEventListener(
'unhandledrejection', function(error){ console.error(error); });
self.addEventListener(
'error', function(error) { console.error(error); });

this.supportsIndexedDB = self.indexedDB != null;
console.log('AppIndexedDBMirrorWorker started...');
};

Expand Down Expand Up @@ -120,8 +122,12 @@
* with the result of the transaction, or rejects if the transaction fails
* with the error reported by the transaction.
*/
operateOnStore: function(operation, storeName, mode, operationArgs) {
operationArgs = Array.from(arguments).slice(3);
operateOnStore: function(operation, storeName, mode) {
if (!self.Promise || !this.supportsIndexedDB) {
return;
}

var operationArgs = Array.from(arguments).slice(3);

return this.openDb().then(function(db) {

Expand Down
3 changes: 2 additions & 1 deletion app-indexeddb-mirror/common-worker-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
self.Event ||
// NOTE(cdata): Have mercy on my soul..
event.__proto__.__proto__.constructor;
var connectEvent = new EventConstructor('connect');

var connectEvent = new EventConstructor('connect');
connectEvent.ports = event.ports;

self.dispatchEvent(connectEvent);
}
}.bind(this));
Expand Down
16 changes: 15 additions & 1 deletion app-indexeddb-mirror/common-worker.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
var BASE_URI = currentScript.ownerDocument.baseURI;

// fallback baseURI
var BASE_URI = document.currentScript ? document.currentScript.baseURI : './';

// Polymer 2 baseURI polyfill for IE and Safari
if (Polymer.Element && window.HTMLImports && HTMLImports.importForElement) {
BASE_URI = HTMLImports.importForElement(document.currentScript).baseURI;

// Polymer 1 or no HTML Imports
} else {
var currentScript = document._currentScript ? document._currentScript :
document.currentScript;
BASE_URI = currentScript.ownerDocument.baseURI;
}

var WORKER_SCOPE_URL =
Polymer.ResolveUrl.resolveUrl('common-worker-scope.js', BASE_URI);

Expand Down
50 changes: 36 additions & 14 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"authors": [
"The Polymer Authors"
],
"version": "1.0.1",
"version": "2.0.0",
"description": "Web Components for managing user data in web apps",
"main": [
"app-storage-behavior.html",
Expand All @@ -16,21 +16,43 @@
"homepage": "",
"private": true,
"dependencies": {
"promise-polyfill": "polymerlabs/promise-polyfill#^1.0.0",
"polymer": "polymer/polymer#^1.2.0"
"polymer": "polymer/polymer#^2.0.0-rc.3"
},
"devDependencies": {
"web-component-tester": "^4.0.0",
"paper-input": "polymerelements/paper-input#^1.0.0",
"moment": "^2.12.0",
"paper-styles": "polymerelements/paper-styles#^1.0.0",
"font-roboto": "polymerelements/font-roboto#^1.0.0",
"iron-flex-layout": "polymerelements/iron-flex-layout#^1.0.0",
"iron-icon": "polymerelements/iron-icon#^1.0.0",
"paper-fab": "polymerelements/paper-fab#^1.0.0",
"iron-icons": "polymerelements/iron-icons#^1.0.0",
"paper-button": "polymerelements/paper-button#^1.0.0",
"platinum-sw": "polymerelements/platinum-sw#^1.3.0"
"iron-flex-layout": "polymerelements/iron-flex-layout#2.0-preview",
"iron-icon": "polymerelements/iron-icon#2.0-preview",
"iron-icons": "polymerelements/iron-icons#2.0-preview",
"moment": "^2.12.0",
"paper-button": "polymerelements/paper-button#2.0-preview",
"paper-fab": "polymerelements/paper-fab#2.0-preview",
"paper-input": "polymerelements/paper-input#2.0-preview",
"paper-styles": "polymerelements/paper-styles#2.0-preview",
"platinum-sw": "polymerelements/platinum-sw#2.0-preview",
"promise-polyfill": "polymerlabs/promise-polyfill#2.0-preview",
"web-component-tester": "Polymer/web-component-tester#^6.0.0-prerelease.6",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0-rc.1"
},
"ignore": []
"variants": {
"1.x": {
"dependencies": {
"polymer": "polymer/polymer#^1.2.0"
},
"devDependencies": {
"font-roboto": "polymerelements/font-roboto#^1.0.0",
"iron-flex-layout": "polymerelements/iron-flex-layout#^1.0.0",
"iron-icon": "polymerelements/iron-icon#^1.0.0",
"iron-icons": "polymerelements/iron-icons#^1.0.0",
"moment": "^2.12.0",
"paper-button": "polymerelements/paper-button#^1.0.0",
"paper-fab": "polymerelements/paper-fab#^1.0.0",
"paper-input": "polymerelements/paper-input#^1.0.0",
"paper-styles": "polymerelements/paper-styles#^1.0.0",
"platinum-sw": "polymerelements/platinum-sw#^1.3.0",
"promise-polyfill": "polymerlabs/promise-polyfill#^1.0.0",
"web-component-tester": "Polymer/web-component-tester#^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.24"
}
}
}
}
24 changes: 24 additions & 0 deletions test/app-indexeddb-mirror/app-indexeddb-mirror.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@
}

suite('<app-indexeddb-mirror>', function() {
// skips tests due to async bug in mocha
this.ctx.skip = function() {
this.pending = true;
}.bind(this);

setup(function(done) {
var featureDetect = new Worker('../feature-detect.js');

var timeout = window.setTimeout(function() {
this.skip();
}.bind(this), 3000);

featureDetect.onmessage = function(e) {
window.clearTimeout(timeout);
var error;
if (e.data !== 'pass') {
this.skip();
}
done();
}.bind(this);

featureDetect.postMessage('featureDetect');
});

teardown(function() {
appStorageTestHelpers.restoreNavigatorOnLine();
return appStorageTestHelpers.deleteIdbDatabase('app-mirror');
Expand Down
32 changes: 17 additions & 15 deletions test/app-localstorage/app-localstorage-document.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,26 @@
<title>app-localstorage tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

<script>
window.addEventListener('WebComponentsReady', function() {
testAppStorageDocumentCompatibility({
tagName: 'app-localstorage-document',
fetchStoredValue: function(storagePath) {
var parts = storagePath.split('.');
var value = JSON.parse(localStorage.getItem('app-localstorage-test'));

parts.shift();

return Promise.resolve(Polymer.Base.get(parts.join('.'), value));
}
});
})
</script>

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>

<link rel="import" href="../../../promise-polyfill/promise-polyfill.html">
<link rel="import" href="../app-storage-compatibility-suite.html">
<link rel="import" href="../../app-localstorage/app-localstorage-document.html">
</head>
Expand All @@ -38,20 +55,5 @@
</template>
</test-fixture>

<script>
document.addEventListener('WebComponentsReady', function() {
testAppStorageDocumentCompatibility({
tagName: 'app-localstorage-document',
fetchStoredValue: function(storagePath) {
var parts = storagePath.split('.');
var value = JSON.parse(localStorage.getItem('app-localstorage-test'));

parts.shift();

return Promise.resolve(Polymer.Base.get(parts.join('.'), value));
}
});
})
</script>
</body>
</html>
1 change: 1 addition & 0 deletions test/app-storage-compatibility-suite.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<script>
(function() {
'use strict';

function testAppStorageDocumentCompatibility(extendedContext) {
var context = {
tagName: 'unknown-element',
Expand Down
42 changes: 0 additions & 42 deletions test/app-storage.html

This file was deleted.

37 changes: 37 additions & 0 deletions test/feature-detect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(function(){

onmessage = function(e) {
if (e.data != 'featureDetect') {
return;
}

if (self.indexedDB == null || self.indexedDB === undefined ||
self.Promise === undefined) {
self.postMessage('fail');
return;
}

var timeout = self.setTimeout(function() { self.postMessage('fail'); },
1000);

self.addEventListener('testWorkerEvents', function() {
self.postMessage('pass');
self.clearTimeout(timeout);
});

try {
var EventConstructor =
self.CustomEvent ||
self.Event ||
// NOTE(cdata): Have mercy on my soul..
event.__proto__.__proto__.constructor;

var testWorkerEvents = new EventConstructor('testWorkerEvents');
self.dispatchEvent(testWorkerEvents);
return;

} catch(e) {
self.postMessage('fail');
}
}
}())
6 changes: 4 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
<body>
<script>
WCT.loadSuites([
'./app-localstorage/app-localstorage-document.html',
'./app-indexeddb-mirror/app-indexeddb-mirror.html'
'./app-localstorage/app-localstorage-document.html?dom=shadow',
'./app-indexeddb-mirror/app-indexeddb-mirror.html?dom=shadow',
'./app-localstorage/app-localstorage-document.html?wc-shadydom=true&wc-ce=true',
'./app-indexeddb-mirror/app-indexeddb-mirror.html?wc-shadydom=true&wc-ce=true'
]);
</script>
</body>
Expand Down