@@ -385,4 +385,51 @@ describe('Runtime checks: should allow element modification', () => {
385
385
srcVal7 : 'http://example4.com/'
386
386
} )
387
387
} )
388
+
389
+ it ( 'Script using parent prototype should execute checking' , async ( ) => {
390
+ const port = server . address ( ) . port
391
+ const page = await browser . newPage ( )
392
+ await gotoAndWait ( page , `http://localhost:${ port } /blank.html` , {
393
+ site : {
394
+ enabledFeatures : [ 'runtimeChecks' ]
395
+ } ,
396
+ featureSettings : {
397
+ runtimeChecks : {
398
+ taintCheck : 'enabled' ,
399
+ matchAllDomains : 'enabled' ,
400
+ matchAllStackDomains : 'enabled' ,
401
+ overloadInstanceOf : 'enabled'
402
+ }
403
+ }
404
+ } )
405
+ // And now with a script that will execute
406
+ const scriptResult = await page . evaluate (
407
+ ( ) => {
408
+ // @ts -expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
409
+ window . scriptDocumentPrototypeRan = false
410
+ const scriptElement = Document . prototype . createElement . call ( window . document , 'script' )
411
+ scriptElement . innerText = 'window.scriptDocumentPrototypeRan = true'
412
+ scriptElement . id = 'scriptDocumentPrototype'
413
+ scriptElement . setAttribute ( 'type' , 'application/javascript' )
414
+ document . body . appendChild ( scriptElement )
415
+ const hadInspectorNode = ! ! document . querySelector ( 'ddg-runtime-checks' )
416
+ const instanceofResult = scriptElement instanceof HTMLScriptElement
417
+ const scripty = document . querySelector ( 'script#scriptDocumentPrototype' )
418
+
419
+ return {
420
+ // @ts -expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
421
+ scriptRan : window . scriptDocumentPrototypeRan ,
422
+ hadInspectorNode,
423
+ instanceofResult,
424
+ type : scripty . getAttribute ( 'type' )
425
+ }
426
+ }
427
+ )
428
+ expect ( scriptResult ) . toEqual ( {
429
+ scriptRan : true ,
430
+ hadInspectorNode : true ,
431
+ instanceofResult : true ,
432
+ type : 'application/javascript'
433
+ } )
434
+ } )
388
435
} )
0 commit comments