tracy icon indicating copy to clipboard operation
tracy copied to clipboard

Form target iframe not catched by Tracy

Open midlan opened this issue 5 years ago • 0 comments

Bug Description

Tracy is not catching request of form with target to hidden iframe. See example below.

Steps To Reproduce

Sample test file:

<?php

require 'vendor/autoload.php';

\Tracy\Debugger::enable(false);

    //form sent
    if (!empty($_POST['data'])) : ?>
<script>
    parent.setHeader(<?php echo json_encode($_POST['data']); ?> + ' recieved!');
</script>
<?php
        exit; //exit to only send script
    endif;

?><!DOCTYPE html>
<html>
  <head>
    <title>Example of async iframe + tracy</title>
  </head>
  <body>
    <iframe name="hiddenIframe" style="display: none;"></iframe>
    <h1 id="status">Wait to send ...</h1>
    <form target="hiddenIframe" action="<?php echo basename(__FILE__); ?>" method="post">
        <input type="text" name="data" />
        <input type="submit" />
    </form>
    <script>
        function setHeader(header) {
            document.getElementById('status').innerText = header;
        }
    </script>
  </body>
</html>

When you hit submit, async request is created but visually tracy did not catch it.

In fact it catched, but it started another tracy instance inside the hidden iframe.

Expected Behavior

I would expect that tracy in the main frame will show the request.

Possible Solution

I think tracy could inject some javascript that will catch form submit event with different target I guess?

midlan avatar Jul 23 '20 12:07 midlan