1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 " />
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 " />
7
+ < meta name ="description " content ="Partytown Test Page " />
8
+ < title > Iframe origin</ title >
9
+ < style >
10
+ body {
11
+ font-family : -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
12
+ Apple Color Emoji, Segoe UI Emoji;
13
+ font-size : 12px ;
14
+ }
15
+
16
+ h1 {
17
+ margin : 0 0 15px 0 ;
18
+ }
19
+
20
+ ul {
21
+ list-style-type : none;
22
+ margin : 0 ;
23
+ padding : 0 ;
24
+ }
25
+
26
+ a {
27
+ display : block;
28
+ padding : 16px 8px ;
29
+ }
30
+
31
+ a : link ,
32
+ a : visited {
33
+ text-decoration : none;
34
+ color : blue;
35
+ }
36
+
37
+ a : hover {
38
+ background-color : # eee ;
39
+ }
40
+
41
+ li {
42
+ display : block;
43
+ height : 80px ;
44
+ }
45
+
46
+ li strong ,
47
+ li code ,
48
+ li button {
49
+ white-space : nowrap;
50
+ margin : 0 5px ;
51
+ min-width : 10px ;
52
+ }
53
+
54
+ iframe {
55
+ width : 100% ;
56
+ height : 36px ;
57
+ border : none;
58
+ }
59
+ </ style >
60
+ < script >
61
+ window . name = 'Main' ;
62
+ </ script >
63
+ < script >
64
+ partytown = {
65
+ logCalls : true ,
66
+ logGetters : true ,
67
+ logSetters : true ,
68
+ logImageRequests : true ,
69
+ logSendBeaconRequests : true ,
70
+ logStackTraces : false ,
71
+ logScriptExecution : true ,
72
+ } ;
73
+ </ script >
74
+ < script src ="/~partytown/debug/partytown.js "> </ script >
75
+ </ head >
76
+
77
+ < body >
78
+ < h1 > Iframe cookie & localStorage</ h1 >
79
+ < ul >
80
+ < li >
81
+ < strong > Same origin cookie set/get</ strong >
82
+ < button id ="sameOriginCookieButton "> Create iframe</ button >
83
+ < code id ="testSameOriginCookie "> </ code >
84
+ < script type ="text/partytown ">
85
+ ( function ( ) {
86
+ const btn = document . getElementById ( 'sameOriginCookieButton' ) ;
87
+ btn . addEventListener ( 'click' , function ( ev ) {
88
+ const elm = document . getElementById ( 'testSameOriginCookie' ) ;
89
+ const iframe = document . createElement ( 'iframe' ) ;
90
+ iframe . id = 'iframe-same-origin-cookie' ;
91
+ iframe . style . height = '60px' ;
92
+ const url = new URL ( '/tests/platform/iframe/cookie.html' , location . origin ) ;
93
+ iframe . src = url . href ;
94
+ elm . parentNode . appendChild ( iframe ) ;
95
+ } ) ;
96
+ } ) ( ) ;
97
+ </ script >
98
+ </ li >
99
+
100
+ < li >
101
+ < strong > Same origin localStorage set/get</ strong >
102
+ < button id ="sameOriginLocalStorageButton "> Create iframe</ button >
103
+ < code id ="testSameOriginLocalStorage "> </ code >
104
+ < script type ="text/partytown ">
105
+ ( function ( ) {
106
+ const btn = document . getElementById ( 'sameOriginLocalStorageButton' ) ;
107
+ btn . addEventListener ( 'click' , function ( ev ) {
108
+ const elm = document . getElementById ( 'testSameOriginLocalStorage' ) ;
109
+ const iframe = document . createElement ( 'iframe' ) ;
110
+ iframe . id = 'iframe-same-origin-localstorage' ;
111
+ iframe . style . height = '60px' ;
112
+ const url = new URL ( '/tests/platform/iframe/localstorage.html' , location . origin ) ;
113
+ iframe . src = url . href ;
114
+ elm . parentNode . appendChild ( iframe ) ;
115
+ } ) ;
116
+ } ) ( ) ;
117
+ </ script >
118
+ </ li >
119
+
120
+ < li >
121
+ < strong > Cross origin cookie set/get</ strong >
122
+ < button id ="crossOriginCookieButton "> Create iframe</ button >
123
+ < code id ="testCrossOriginCookie "> </ code >
124
+ < script type ="text/partytown ">
125
+ ( function ( ) {
126
+ const btn = document . getElementById ( 'crossOriginCookieButton' ) ;
127
+ btn . addEventListener ( 'click' , function ( ev ) {
128
+ const url = new URL ( '/tests/platform/iframe/cookie.html' , location . origin ) ;
129
+ fetch ( url )
130
+ . then ( response => response . text ( ) )
131
+ . then ( htmlContent => {
132
+ // simulating cross origin iframe by using a datauri
133
+ // which won't have the same origin
134
+ const dataUri = `data:text/html;base64,${ btoa ( htmlContent ) } ` ;
135
+ const elm = document . getElementById ( 'testCrossOriginCookie' ) ;
136
+ const iframe = document . createElement ( 'iframe' ) ;
137
+ iframe . id = 'iframe-cross-origin-cookie' ;
138
+ iframe . style . height = '60px' ;
139
+ iframe . src = dataUri ;
140
+ elm . parentNode . appendChild ( iframe ) ;
141
+ } ) ;
142
+ } ) ;
143
+ } ) ( ) ;
144
+ </ script >
145
+ </ li >
146
+
147
+ < li >
148
+ < strong > Cross origin localStorage set/get</ strong >
149
+ < button id ="crossOriginLocalStorageButton "> Create iframe</ button >
150
+ < code id ="testCrossOriginLocalStorage "> </ code >
151
+ < script type ="text/partytown ">
152
+ ( function ( ) {
153
+ const btn = document . getElementById ( 'crossOriginLocalStorageButton' ) ;
154
+ btn . addEventListener ( 'click' , function ( ev ) {
155
+ const url = new URL ( '/tests/platform/iframe/localstorage.html' , location . origin ) ;
156
+ fetch ( url )
157
+ . then ( response => response . text ( ) )
158
+ . then ( htmlContent => {
159
+ // simulating cross origin iframe by using a datauri
160
+ // which won't have the same origin
161
+ const dataUri = `data:text/html;base64,${ btoa ( htmlContent ) } ` ;
162
+ const elm = document . getElementById ( 'testCrossOriginLocalStorage' ) ;
163
+ const iframe = document . createElement ( 'iframe' ) ;
164
+ iframe . id = 'iframe-cross-origin-localstorage' ;
165
+ iframe . style . height = '60px' ;
166
+ iframe . src = dataUri ;
167
+ elm . parentNode . appendChild ( iframe ) ;
168
+ } ) ;
169
+ } ) ;
170
+ } ) ( ) ;
171
+ </ script >
172
+ </ li >
173
+ </ ul >
174
+
175
+ < script type ="text/partytown ">
176
+ ( function ( ) {
177
+ document . body . classList . add ( 'completed' ) ;
178
+ } ) ( ) ;
179
+ </ script >
180
+ < hr />
181
+ < p > < a href ="/tests/ "> All Tests</ a > </ p >
182
+ </ body >
183
+
184
+ </ html >
0 commit comments