1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8
+ < title > Script execution XCTO Tests</ title >
9
+ < script src ="/_hp/resources/testharness.sub.js "> </ script >
10
+ < script src ="/_hp/resources/store_results.sub.js "> </ script >
11
+ </ head >
12
+
13
+ < body >
14
+
15
+ </ body >
16
+
17
+
18
+ < script >
19
+ let resp_type = urlParams . get ( "resp_type" ) || "debug" ;
20
+ var count = 0 ;
21
+ function script_sniffing_test ( element , sandbox , test_info , url , origin , response_id ) {
22
+ /*
23
+ url: str, URL to be tested (next in the framing chain)
24
+ origin: str, Origin of the URL to be tested
25
+ response_id: int, ID of the response element (final response of the chain)
26
+ element: str, iframe/object/embed
27
+ sandbox: bool whether to add the sandbox attribute to the next frame
28
+ test_info: str, additional information about the test (direct, sandbox, nested (A->B->A->A))
29
+ */
30
+ test_name = `sniffing_${ element } |${ sandbox } |${ test_info } |${ origin } |${ response_id } ` ;
31
+ //console.log(url, response_id, test_name);
32
+ async_test ( t => {
33
+ t . set_test_info ( url , test_info ) ;
34
+ const i = document . createElement ( element ) ;
35
+ count = count + 1 ;
36
+ i . id = count ;
37
+ let origin = location . origin ;
38
+ let resp = 1 ;
39
+ let nest = 0 ;
40
+ let final_url = url + response_id + `&count=${ i . id } &nest=${ nest } &origin=${ origin } &element=${ element } &resp=${ resp } `
41
+ i . src = final_url ;
42
+
43
+ // Wait for 90% of test_timeout; then report that no message was received!
44
+ let timer = t . step_timeout ( ( ) => {
45
+ t . report_outcome ( "message timeout" ) ;
46
+ t . done ( ) ;
47
+ } , 0.9 * test_timeout ) ;
48
+ // Report that a message was received
49
+ waitForMessageFrom ( i , t ) . then ( t . step_func_done ( e => {
50
+ clearTimeout ( timer ) ;
51
+ t . report_outcome ( e . data . message ) ;
52
+ } ) ) ;
53
+ // Cleanup function (remove the frame after the test)
54
+ t . add_cleanup ( ( ) => {
55
+ i . remove ( ) ;
56
+ } ) ;
57
+ // Start the test
58
+ document . body . append ( i ) ;
59
+ } , test_name ) ;
60
+ }
61
+
62
+ // A -> B (XCTO): send message
63
+ const simple_sniffing = script_sniffing_test . bind ( null , 'script' , false , "direct" ) ;
64
+ simple_sniffing . element_relation = "script_direct" ;
65
+ let test_declarations ;
66
+ test_declarations = [ simple_sniffing ] ;
67
+ const path = '/_hp/server/responses.py?feature_group=xcto&resp_id=' ;
68
+ const label = 'XCTO' ;
69
+ run_tests ( test_declarations , path , label ) ;
70
+
71
+ </ script >
72
+
73
+ </ html >
0 commit comments