11'use strict' ;
22
3+ // Historically:
34// only running in Chrome and Firefox due to various bugs.
45// IE: https://connect.microsoft.com/IE/feedback/details/866495
56// Safari: doesn't have IndexedDB or WebSQL in a WW
67// NodeWebkit: not sure what the issue is
7-
8- var isNodeWebkit = typeof window !== 'undefined' &&
9- typeof process !== 'undefined' ;
10-
11- if ( ( window && typeof window . Worker === 'function' ) &&
12- ! isNodeWebkit && ! testUtils . isIE ( ) &&
13- ( ( window && window . chrome ) || ( navigator && / F i r e f o x / . test ( navigator . userAgent ) ) ) ) {
14- runTests ( ) ;
15- }
16-
17- function runTests ( ) {
8+ // Now:
9+ // skipped everywhere, as they weren't being run anyway.
10+ // See: https://github.com/pouchdb/pouchdb/issues/8680
11+ // TODO re-introduce these tests in environments where they are appropriate.
12+ describe . skip ( 'browser.worker.js' , function ( ) {
1813
1914 var worker ;
15+ var dbs = { } ;
2016
2117 before ( function ( ) {
2218 worker = new Worker ( 'worker.js' ) ;
@@ -32,10 +28,6 @@ function runTests() {
3228 worker . postMessage ( [ 'source' , sourceFile ] ) ;
3329 } ) ;
3430
35- after ( function ( ) {
36- worker . terminate ( ) ;
37- } ) ;
38-
3931 function workerPromise ( message ) {
4032 return new Promise ( function ( resolve , reject ) {
4133 worker . onerror = function ( e ) {
@@ -48,90 +40,86 @@ function runTests() {
4840 } ) ;
4941 }
5042
51- describe ( 'browser.worker.js' , function ( ) {
52-
53- var dbs = { } ;
54-
55- beforeEach ( function ( done ) {
56- dbs . name = testUtils . adapterUrl ( 'local' , 'testdb' ) ;
57- dbs . remote = testUtils . adapterUrl ( 'http' , 'test_repl_remote' ) ;
58- testUtils . cleanup ( [ dbs . name , dbs . remote ] , done ) ;
59- } ) ;
43+ beforeEach ( function ( done ) {
44+ dbs . name = testUtils . adapterUrl ( 'local' , 'testdb' ) ;
45+ dbs . remote = testUtils . adapterUrl ( 'http' , 'test_repl_remote' ) ;
46+ testUtils . cleanup ( [ dbs . name , dbs . remote ] , done ) ;
47+ } ) ;
6048
61- after ( function ( done ) {
62- testUtils . cleanup ( [ dbs . name , dbs . remote ] , done ) ;
63- } ) ;
49+ after ( function ( done ) {
50+ worker . terminate ( ) ;
51+ testUtils . cleanup ( [ dbs . name , dbs . remote ] , done ) ;
52+ } ) ;
6453
65- it ( 'create it' , function ( ) {
66- return workerPromise ( 'ping' ) . then ( function ( data ) {
67- data . should . equal ( 'pong' ) ;
68- } ) ;
54+ it ( 'create it' , function ( ) {
55+ return workerPromise ( 'ping' ) . then ( function ( data ) {
56+ data . should . equal ( 'pong' ) ;
6957 } ) ;
58+ } ) ;
7059
71- it ( 'check pouch version' , function ( ) {
72- return workerPromise ( 'version' ) . then ( function ( data ) {
73- PouchDB . version . should . equal ( data ) ;
74- } ) ;
60+ it ( 'check pouch version' , function ( ) {
61+ return workerPromise ( 'version' ) . then ( function ( data ) {
62+ PouchDB . version . should . equal ( data ) ;
7563 } ) ;
64+ } ) ;
7665
77- it ( 'create remote db' , function ( ) {
78- return workerPromise ( [ 'create' , dbs . remote ] ) . then ( function ( data ) {
79- data . should . equal ( 'lala' ) ;
80- } ) ;
66+ it ( 'create remote db' , function ( ) {
67+ return workerPromise ( [ 'create' , dbs . remote ] ) . then ( function ( data ) {
68+ data . should . equal ( 'lala' ) ;
8169 } ) ;
70+ } ) ;
8271
83- it ( 'create local db' , function ( ) {
84- return workerPromise ( [ 'create' , dbs . name ] ) . then ( function ( data ) {
85- data . should . equal ( 'lala' ) ;
86- } ) ;
72+ it ( 'create local db' , function ( ) {
73+ return workerPromise ( [ 'create' , dbs . name ] ) . then ( function ( data ) {
74+ data . should . equal ( 'lala' ) ;
8775 } ) ;
76+ } ) ;
8877
89- it ( 'add doc with blob attachment' , function ( ) {
90- return workerPromise ( [ 'postAttachmentThenAllDocs' , dbs . name ] ) . then ( function ( data ) {
91- data . title . should . equal ( 'lalaa' ) ;
92- } ) ;
78+ it ( 'add doc with blob attachment' , function ( ) {
79+ return workerPromise ( [ 'postAttachmentThenAllDocs' , dbs . name ] ) . then ( function ( data ) {
80+ data . title . should . equal ( 'lalaa' ) ;
9381 } ) ;
82+ } ) ;
9483
95- it ( 'put an attachment' , function ( ) {
96- var blob = new Blob ( [ 'foobar' ] , { type : 'text/plain' } ) ;
97- var message = [ 'putAttachment' , dbs . name , 'doc' , 'att.txt' , blob ,
98- 'text/plain' ] ;
99- return workerPromise ( message ) . then ( function ( blob ) {
100- blob . type . should . equal ( 'text/plain' ) ;
101- blob . size . should . equal ( 6 ) ;
102- } ) ;
84+ it ( 'put an attachment' , function ( ) {
85+ var blob = new Blob ( [ 'foobar' ] , { type : 'text/plain' } ) ;
86+ var message = [ 'putAttachment' , dbs . name , 'doc' , 'att.txt' , blob ,
87+ 'text/plain' ] ;
88+ return workerPromise ( message ) . then ( function ( blob ) {
89+ blob . type . should . equal ( 'text/plain' ) ;
90+ blob . size . should . equal ( 6 ) ;
10391 } ) ;
92+ } ) ;
10493
105- it ( 'total_rows consistent between worker and main thread' , function ( ) {
106- var db = new PouchDB ( dbs . name ) ;
94+ it ( 'total_rows consistent between worker and main thread' , function ( ) {
95+ var db = new PouchDB ( dbs . name ) ;
10796
108- // this test only makes sense for idb
109- if ( db . adapter !== 'idb' ) {
110- return ;
111- }
97+ // this test only makes sense for idb
98+ if ( db . adapter !== 'idb' ) {
99+ return ;
100+ }
112101
113- // both threads agree the count is 0
102+ // both threads agree the count is 0
103+ return testUtils . Promise . all ( [
104+ db . allDocs ( ) . then ( function ( res ) {
105+ res . total_rows . should . equal ( 0 ) ;
106+ } ) ,
107+ workerPromise ( [ 'allDocs' , dbs . name ] ) . then ( function ( res ) {
108+ res . total_rows . should . equal ( 0 ) ;
109+ } )
110+ ] ) . then ( function ( ) {
111+ // post a doc
112+ return db . post ( { } ) ;
113+ } ) . then ( function ( ) {
114+ // both threads agree the count is 1
114115 return testUtils . Promise . all ( [
115116 db . allDocs ( ) . then ( function ( res ) {
116- res . total_rows . should . equal ( 0 ) ;
117+ res . total_rows . should . equal ( 1 ) ;
117118 } ) ,
118119 workerPromise ( [ 'allDocs' , dbs . name ] ) . then ( function ( res ) {
119- res . total_rows . should . equal ( 0 ) ;
120+ res . total_rows . should . equal ( 1 ) ;
120121 } )
121- ] ) . then ( function ( ) {
122- // post a doc
123- return db . post ( { } ) ;
124- } ) . then ( function ( ) {
125- // both threads agree the count is 1
126- return testUtils . Promise . all ( [
127- db . allDocs ( ) . then ( function ( res ) {
128- res . total_rows . should . equal ( 1 ) ;
129- } ) ,
130- workerPromise ( [ 'allDocs' , dbs . name ] ) . then ( function ( res ) {
131- res . total_rows . should . equal ( 1 ) ;
132- } )
133- ] ) ;
134- } ) ;
122+ ] ) ;
135123 } ) ;
136124 } ) ;
137- }
125+ } ) ;
0 commit comments