@@ -5,6 +5,7 @@ let fb_wrap = 'https://facebook.com/l.php?u=' + destination;
5
5
let fb_xss = 'https://facebook.com/l.php?u=javascript://bad.site/%250Aalert(1)' ;
6
6
let g_wrap = 'https://www.google.com/url?q=' + destination ;
7
7
let g_ping = '/url?url=' + destination ;
8
+ let tumblr_wrap = 'https://t.umblr.com/redirect?z=' + destination ;
8
9
9
10
function makeLink ( href ) {
10
11
let element = document . createElement ( 'a' ) ;
@@ -164,4 +165,38 @@ QUnit.test('google search de-instrumentation', (assert) => {
164
165
fixture . appendChild ( util_script ) ;
165
166
} ) ;
166
167
168
+ QUnit . test ( 'tumblr link unwrapping' , ( assert ) => {
169
+ const NUM_CHECKS = 2 ,
170
+ done = assert . async ( ) ;
171
+ assert . expect ( NUM_CHECKS ) ;
172
+
173
+ let fixture = document . getElementById ( 'qunit-fixture' ) ;
174
+ let tumblr_link = makeLink ( tumblr_wrap ) ;
175
+
176
+ // create first-party utility script
177
+ let util_script = document . createElement ( 'script' ) ;
178
+ util_script . src = '../js/firstparties/lib/utils.js' ;
179
+
180
+ // create the content script
181
+ let tumblr_script = document . createElement ( 'script' ) ;
182
+ tumblr_script . src = '../js/firstparties/tumblr.js' ;
183
+ tumblr_script . onload = function ( ) {
184
+ assert . equal ( tumblr_link . href , destination , 'unwrapped tumblr link' ) ;
185
+ assert . ok ( tumblr_link . rel . includes ( 'noreferrer' ) ,
186
+ 'added noreferrer to tumblr link' ) ;
187
+
188
+ unstub ( ) ;
189
+ done ( ) ;
190
+ } ;
191
+
192
+ // after the utility script has finished loading, add the content script
193
+ util_script . onload = function ( ) {
194
+ fixture . append ( tumblr_script ) ;
195
+ } ;
196
+
197
+ stub ( [ tumblr_link ] , '/url?' ) ;
198
+ fixture . appendChild ( tumblr_link ) ;
199
+ fixture . appendChild ( util_script ) ;
200
+ } ) ;
201
+
167
202
} ( ) ) ;
0 commit comments