File tree Expand file tree Collapse file tree 9 files changed +190
-2
lines changed
integration/pages/duckplayer/js
windows/pages/duckplayer/js Expand file tree Collapse file tree 9 files changed +190
-2
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,18 @@ jobs:
44
44
45
45
- name : Collect commit ranges
46
46
run : |
47
- echo "CHANGELOG=$(git log main --since "$(git show -s --format=%ci $(git rev-list --tags --max-count=1))" --pretty='format:- %s')" >> $GITHUB_OUTPUT
47
+ CHANGELOG="$(git log main --since "$(git show -s --format=%ci $(git rev-list --tags --max-count=1))" --pretty='format:- %s')"
48
+ DELIMITER=$(echo $RANDOM | md5sum | head -c 20;)
49
+ echo "CHANGELOG<<$DELIMITER" >> $GITHUB_ENV
50
+ echo "$CHANGELOG" >> $GITHUB_ENV
51
+ echo "$DELIMITER" >> $GITHUB_ENV
48
52
49
53
- name : Create Release
50
54
uses : softprops/action-gh-release@v1
51
55
env :
52
56
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53
57
with :
54
- body_path : ${{ steps.version.outputs .CHANGELOG }}
58
+ body_path : ${{ env .CHANGELOG }}
55
59
draft : false
56
60
prerelease : false
57
61
tag_name : ${{ github.event.inputs.version }}
Original file line number Diff line number Diff line change 776
776
return new Template ( strings , values ) ;
777
777
}
778
778
779
+ // pages/duckplayer/src/js/storage.js
780
+ function deleteStorage ( subject ) {
781
+ Object . keys ( subject ) . forEach ( ( key ) => {
782
+ if ( key . indexOf ( "yt-player" ) === 0 ) {
783
+ return ;
784
+ }
785
+ subject . removeItem ( key ) ;
786
+ } ) ;
787
+ }
788
+ function deleteAllCookies ( ) {
789
+ const cookies = document . cookie . split ( ";" ) ;
790
+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
791
+ const cookie = cookies [ i ] ;
792
+ const eqPos = cookie . indexOf ( "=" ) ;
793
+ const name = eqPos > - 1 ? cookie . substr ( 0 , eqPos ) : cookie ;
794
+ document . cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=youtube-nocookie.com;path=/;" ;
795
+ }
796
+ }
797
+ function initStorage ( ) {
798
+ window . addEventListener ( "unload" , ( ) => {
799
+ deleteStorage ( localStorage ) ;
800
+ deleteStorage ( sessionStorage ) ;
801
+ deleteAllCookies ( ) ;
802
+ } ) ;
803
+ window . addEventListener ( "load" , ( ) => {
804
+ deleteStorage ( localStorage ) ;
805
+ deleteStorage ( sessionStorage ) ;
806
+ deleteAllCookies ( ) ;
807
+ } ) ;
808
+ }
809
+
779
810
// pages/duckplayer/src/js/index.js
780
811
var VideoPlayer = {
781
812
/**
1372
1403
} ) ;
1373
1404
MouseMove . init ( ) ;
1374
1405
} ) ;
1406
+ initStorage ( ) ;
1375
1407
} ) ( ) ;
Original file line number Diff line number Diff line change
1
+ function deleteStorage ( subject ) {
2
+ Object . keys ( subject ) . forEach ( ( key ) => {
3
+ if ( key . indexOf ( 'yt-player' ) === 0 ) {
4
+ return
5
+ }
6
+ subject . removeItem ( key )
7
+ } )
8
+ }
9
+
10
+ function deleteAllCookies ( ) {
11
+ const cookies = document . cookie . split ( ';' )
12
+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
13
+ const cookie = cookies [ i ]
14
+ const eqPos = cookie . indexOf ( '=' )
15
+ const name = eqPos > - 1 ? cookie . substr ( 0 , eqPos ) : cookie
16
+ document . cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=youtube-nocookie.com;path=/;'
17
+ }
18
+ }
19
+
20
+ export function initStorage ( ) {
21
+ window . addEventListener ( 'unload' , ( ) => {
22
+ deleteStorage ( localStorage )
23
+ deleteStorage ( sessionStorage )
24
+ deleteAllCookies ( )
25
+ } )
26
+
27
+ window . addEventListener ( 'load' , ( ) => {
28
+ deleteStorage ( localStorage )
29
+ deleteStorage ( sessionStorage )
30
+ deleteAllCookies ( )
31
+ } )
32
+ }
Original file line number Diff line number Diff line change 776
776
return new Template ( strings , values ) ;
777
777
}
778
778
779
+ // pages/duckplayer/src/js/storage.js
780
+ function deleteStorage ( subject ) {
781
+ Object . keys ( subject ) . forEach ( ( key ) => {
782
+ if ( key . indexOf ( "yt-player" ) === 0 ) {
783
+ return ;
784
+ }
785
+ subject . removeItem ( key ) ;
786
+ } ) ;
787
+ }
788
+ function deleteAllCookies ( ) {
789
+ const cookies = document . cookie . split ( ";" ) ;
790
+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
791
+ const cookie = cookies [ i ] ;
792
+ const eqPos = cookie . indexOf ( "=" ) ;
793
+ const name = eqPos > - 1 ? cookie . substr ( 0 , eqPos ) : cookie ;
794
+ document . cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=youtube-nocookie.com;path=/;" ;
795
+ }
796
+ }
797
+ function initStorage ( ) {
798
+ window . addEventListener ( "unload" , ( ) => {
799
+ deleteStorage ( localStorage ) ;
800
+ deleteStorage ( sessionStorage ) ;
801
+ deleteAllCookies ( ) ;
802
+ } ) ;
803
+ window . addEventListener ( "load" , ( ) => {
804
+ deleteStorage ( localStorage ) ;
805
+ deleteStorage ( sessionStorage ) ;
806
+ deleteAllCookies ( ) ;
807
+ } ) ;
808
+ }
809
+
779
810
// pages/duckplayer/src/js/index.js
780
811
var VideoPlayer = {
781
812
/**
1372
1403
} ) ;
1373
1404
MouseMove . init ( ) ;
1374
1405
} ) ;
1406
+ initStorage ( ) ;
1375
1407
} ) ( ) ;
Original file line number Diff line number Diff line change
1
+ function deleteStorage ( subject ) {
2
+ Object . keys ( subject ) . forEach ( ( key ) => {
3
+ if ( key . indexOf ( 'yt-player' ) === 0 ) {
4
+ return
5
+ }
6
+ subject . removeItem ( key )
7
+ } )
8
+ }
9
+
10
+ function deleteAllCookies ( ) {
11
+ const cookies = document . cookie . split ( ';' )
12
+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
13
+ const cookie = cookies [ i ]
14
+ const eqPos = cookie . indexOf ( '=' )
15
+ const name = eqPos > - 1 ? cookie . substr ( 0 , eqPos ) : cookie
16
+ document . cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=youtube-nocookie.com;path=/;'
17
+ }
18
+ }
19
+
20
+ export function initStorage ( ) {
21
+ window . addEventListener ( 'unload' , ( ) => {
22
+ deleteStorage ( localStorage )
23
+ deleteStorage ( sessionStorage )
24
+ deleteAllCookies ( )
25
+ } )
26
+
27
+ window . addEventListener ( 'load' , ( ) => {
28
+ deleteStorage ( localStorage )
29
+ deleteStorage ( sessionStorage )
30
+ deleteAllCookies ( )
31
+ } )
32
+ }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import {
37
37
} from '../../../../../messaging/index.js'
38
38
import { DuckPlayerPageMessages , UserValues } from './messages'
39
39
import { html } from '../../../../../../src/dom-utils'
40
+ import { initStorage } from './storage'
40
41
41
42
// for docs
42
43
export { DuckPlayerPageMessages , UserValues }
@@ -761,3 +762,5 @@ document.addEventListener('DOMContentLoaded', () => {
761
762
} )
762
763
MouseMove . init ( )
763
764
} )
765
+
766
+ initStorage ( )
Original file line number Diff line number Diff line change
1
+ function deleteStorage ( subject ) {
2
+ Object . keys ( subject ) . forEach ( ( key ) => {
3
+ if ( key . indexOf ( 'yt-player' ) === 0 ) {
4
+ return
5
+ }
6
+ subject . removeItem ( key )
7
+ } )
8
+ }
9
+
10
+ function deleteAllCookies ( ) {
11
+ const cookies = document . cookie . split ( ';' )
12
+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
13
+ const cookie = cookies [ i ]
14
+ const eqPos = cookie . indexOf ( '=' )
15
+ const name = eqPos > - 1 ? cookie . substr ( 0 , eqPos ) : cookie
16
+ document . cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=youtube-nocookie.com;path=/;'
17
+ }
18
+ }
19
+
20
+ export function initStorage ( ) {
21
+ window . addEventListener ( 'unload' , ( ) => {
22
+ deleteStorage ( localStorage )
23
+ deleteStorage ( sessionStorage )
24
+ deleteAllCookies ( )
25
+ } )
26
+
27
+ window . addEventListener ( 'load' , ( ) => {
28
+ deleteStorage ( localStorage )
29
+ deleteStorage ( sessionStorage )
30
+ deleteAllCookies ( )
31
+ } )
32
+ }
Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ test.describe('duckplayer iframe', () => {
28
28
await duckplayer . hasShownErrorMessage ( )
29
29
await duckplayer . hasNotAddedIframe ( )
30
30
} )
31
+ test ( 'clears storage' , async ( { page } , workerInfo ) => {
32
+ const duckplayer = DuckPlayerPage . create ( page , workerInfo )
33
+ await duckplayer . openWithVideoID ( )
34
+ await duckplayer . withStorageValues ( )
35
+ await duckplayer . storageClearedAfterReload ( )
36
+ } )
31
37
} )
32
38
33
39
test . describe ( 'duckplayer toolbar' , ( ) => {
Original file line number Diff line number Diff line change @@ -247,6 +247,21 @@ export class DuckPlayerPage {
247
247
} )
248
248
}
249
249
250
+ async withStorageValues ( ) {
251
+ await this . page . evaluate ( ( ) => {
252
+ localStorage . setItem ( 'foo' , 'bar' )
253
+ localStorage . setItem ( 'yt-player-other' , 'baz' )
254
+ } )
255
+ }
256
+
257
+ async storageClearedAfterReload ( ) {
258
+ await this . page . reload ( )
259
+ const storaget = await this . page . evaluate ( ( ) => localStorage )
260
+ expect ( storaget ) . toMatchObject ( {
261
+ 'yt-player-other' : 'baz'
262
+ } )
263
+ }
264
+
250
265
/**
251
266
* We test the fully built artifacts, so for each test run we need to
252
267
* select the correct HTML file.
You can’t perform that action at this time.
0 commit comments