4 DOM checker - test target page
5 ------------------------------
7 Authors: Michal Zalewski <lcamtuf@google.com>
8 Filipe Almeida <filipe@google.com>
10 Copyright 2008 by Google Inc. All Rights Reserved.
12 Licensed under the Apache License, Version 2.0 (the "License");
13 you may not use this file except in compliance with the License.
14 You may obtain a copy of the License at
16 http://www.apache.org/licenses/LICENSE-2.0
18 Unless required by applicable law or agreed to in writing, software
19 distributed under the License is distributed on an "AS IS" BASIS,
20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 See the License for the specific language governing permissions and
22 limitations under the License.
26 <script src=
"dom_config.js"></script>
30 var private_var
= 1; // We'll try to set it across domains.
31 var ipc_page
; // IPC page location
32 var queue_timer
; // IPC queue handling timer
33 var idle
= true; // IPC handler state
34 var prev_hval
= 'NONE'; // Previous IPC command
35 var idle_cycles
= 0; // Number of cycles spend in idle
37 /* Try to inject a variable to paren't namespace by defining a getter in
41 top
.__defineGetter__('injected_var', function() {return 1;})
45 /* Update IPC frame location as needed, set timers. */
46 function page_init() {
48 ipc_page
= 'http://' + main_host
+ '/' + main_dir
+ '/dom_blank_page.html';
49 document
.getElementById('ipc_write').src
= ipc_page
+ '#2';
51 // log('Local ipc_write initialized to ' + ipc_page);
53 queue_timer
= setInterval('get_ipc_command()',250);
58 /* IPC subsystem logging (debugging purposes only) */
60 var e
= document
.createElement('li');
62 document
.getElementById('log').appendChild(e
);
66 /* Wait for IPC state change, execute command, send results. */
67 function get_ipc_command() {
71 try { hval
= top
.frames
['ipc_read'].location
.hash
; } catch (e
) {
72 // log('IPC command read failed from external ipc_read.');
76 if (hval
== prev_hval
|| hval
== '' || hval
== undefined || hval
== 'NONE') {
80 if (idle_cycles
== 200) {
81 // log('Entered power saving mode.');
82 clearInterval(queue_timer
);
83 queue_timer
= setInterval('get_ipc_command()',250);
94 // log('Entered full speed mode.');
95 clearInterval(queue_timer
);
96 queue_timer
= setInterval('get_ipc_command()',1);
101 // log('Got IPC command ' + hval + ' (prev: ' + prev_hval + ')');
107 hval
= hval
.substr(1);
109 if (hval
== 'RESET') res
= 2;
111 if (eval(unescape(hval
))) res
= 1;
113 // log('Evaluation exception! Final was: ' + unescape(hval));
116 document
.getElementById('ipc_write').src
= ipc_page
+ '#' + res
;
121 <title>DOM checker victim page
</title>
122 <body onload=
"page_init()">
124 <!-- Some bogus page elements to make it possible to enumerate arrays. -->
126 <style name=ns
>MENU { margin:
1em }
</style>
128 <img src=
"#bad" name=ni
>
130 <form name=nf method=post action=foo
>
131 <input type=hidden name=foo value=bar
>
134 <h1><a href=
"#bad" name=nl
>Hi mom!
</a></h1>
138 <embed name=ne
></embed>
140 <object name=no
></object>
142 <applet name=na
></applet>
144 <!-- Log container -->
148 <!-- Nested subframe used for about:blank tests -->
149 <iframe id=nf name=nf
src=
"about:blank">
153 <iframe id=ipc_write name=ipc_write
></iframe>