[webkit-dev] how to create a test that can perform actions while resources are still loading?

Dmitry Titov dimich at chromium.org
Thu Oct 7 20:22:21 PDT 2010


It will work, but you need to add more to it, like this:

<?php
header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: text/html; charset=utf-8");
echo("<script>parent.reportLoading('start')</script>");
echo("<body");
for ( $counter = 0; $counter <= 1000; $counter += 1) {
    echo("<span>A bunch of text in the body</span>");
}
sleep(2);
echo("<script>parent.reportLoading('done')</script>");
?>

The trick is to make the text big enough for various network components to
decide to stop accumulating bytes and send them to the receiver. 'flush()'
etc may only affect part of the pipeline. The example above runs a loop and
builds up enough text in the body. That makes using 'flush()' unnecessary as
well.

Also, I believe we have a bug in TextResourceDecoder::checkForHeadCharset,
it has incorrect condition for exit from the loop. This function tries to
find 'charset' in <head> section or in first 1024 bytes, whatever ends last.
Unfortunately, it checks for 1024 only on tag boundaries after first
non-head tag, so if you have a huge body with just text in it, the parser
will never receive a byte before </body>. I'll fix this soon but for now
those <span> tags in the loop will do the trick.

Dmitry

On Thu, Oct 7, 2010 at 5:12 PM, Jenn Braithwaite (胡慧鋒) <jennb at google.com>wrote:

> I need the inline script to be in the iframe content so that the test does
> not execute until the iframe has started loading (but has not completed).  I
> tried the php below, but the script doesn't execute until after the sleep. I
> don't know php.  Is my php wrong?  Or does DRT buffer the response until the
> entire response is complete?
>
> <?php
> header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
> header("Cache-Control: no-cache, no-store, must-revalidate");
> header("Pragma: no-cache");
> header("Content-Type: text/html; charset=utf-8");
> echo("<script>parent.opener.test();</script>");
> ob_flush();
> flush();
> sleep(10);
> ?>
>
> Thanks,
> Jenn
>
> On Thu, Oct 7, 2010 at 8:15 AM, Ojan Vafai <ojan at chromium.org> wrote:
>
>> On Wed, Oct 6, 2010 at 4:42 PM, Darin Adler <darin at apple.com> wrote:
>>
>>> On Oct 6, 2010, at 4:36 PM, Jenn Braithwaite (胡慧鋒) wrote:
>>>
>>> > I've also tried making this an http test using a slow loading iframe,
>>> but the window onload handler for the page does not run until after its
>>> iframe has finished loading.
>>>
>>> This seems OK. You can put your test code somewhere other than the load
>>> handler. For example, an inline script:
>>>
>>>    <script>
>>>    test();
>>>    </script>
>>>
>>> That will run right away and won’t wait for the window load event.
>>>
>>
>> I'm not 100% sure, so take this with a grain of salt, but I think there
>> are cases where iframes the load immediately (e.g. if the resource is
>> cached).
>>
>> To avoid race conditions, I think you need the frames to actually never
>> finish loading. I thought there were some HTTP tests that have resources
>> that intentionally never finish loading. I'd look in the
>> LayoutTests/http/tests for files with 'slow' in the name.
>>
>> Ojan
>>
>
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20101007/a22f28cf/attachment.html>


More information about the webkit-dev mailing list