<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>31626</bug_id>
          
          <creation_ts>2009-11-18 05:24:37 -0800</creation_ts>
          <short_desc>[Qt] layoutTestController.notifyDone() not working when the frame was reloaded.</short_desc>
          <delta_ts>2010-06-17 02:59:06 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>37725</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Qt</keywords>
          <priority>P3</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kenneth Rohde Christiansen">kenneth</reporter>
          <assigned_to name="QtWebKit Unassigned">webkit-qt-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>abecsi</cc>
    
    <cc>darin</cc>
    
    <cc>hausmann</cc>
    
    <cc>jturcotte</cc>
    
    <cc>laszlo.gombos</cc>
    
    <cc>loki</cc>
    
    <cc>ossy</cc>
    
    <cc>robert</cc>
    
    <cc>sam</cc>
    
    <cc>tonikitoo</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>164548</commentid>
    <comment_count>0</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 05:24:37 -0800</bug_when>
    <thetext>So let&apos;s see if I can explain this easily.

Lets focus on one of the layout tests fast/dom/javascript-url-crash-function.html resulting in timeout.

This test calls waitUntilDone from the mainframe and creates an iframe, calling a function and then calling notifyDone.

 9 if (window.layoutTestController) {
10     layoutTestController.dumpAsText();
11     layoutTestController.dumpChildFramesAsText();
12     layoutTestController.waitUntilDone();
13 }

This above part works perfectly fine.

Now looking at the code exporting our QObject based LayoutTestController to JS, initJSObjects is called 3 times, which might seem strange. The last two are called for the iframe. It is not that strange if you look at the code of the iframe

 1 &lt;script&gt;
 2 function test()
 3 {
 4     (function ()
 5     {
 6         (function ()
 7         {
 8             (function ()
 9             {
10                 frameElement.src = &quot;javascript:&apos;&lt;pre&gt;PASS: You didn\\&apos;t crash.&lt;/pre&gt;&apos;&quot;;
11             })()
12         })()
13     })()
14 }
15
16 setTimeout(function ()
17 {
18     test();
19     if (window.layoutTestController)
20         layoutTestController.notifyDone();
21
22 }, 0);
23 &lt;/script&gt;

As you notice, the frameElement.src reloads the frame, so the javaScriptWindowObjectCleared () signal will be called again, resulting in initJSObjects being called.

OK, let&apos;s get to the problem.

19     if (window.layoutTestController)
20         layoutTestController.notifyDone();

is not working! window.layoutTestController is true, but layoutTestController.notifyDone() does nothing. Replacing it with window.layoutTestController.notifyDone() make the test pass, but isn&apos;t right.

The frameElement.src = is the result of this. Out commenting that instead of adding the window. makes the test not timeout.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164630</commentid>
    <comment_count>1</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 10:43:47 -0800</bug_when>
    <thetext>Changing frameElement.src to refer an actual file, actually works, so it seems like an issue with javascript: navigations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164638</commentid>
    <comment_count>2</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 11:30:12 -0800</bug_when>
    <thetext>I started to follow the flow when frameElement.src = &quot;javascript:...&quot; is executed.

The flow is:

scheduleLocationChange -&gt;
schedule -&gt; 
startTimer (case ScheduledRedirection::redirection:) -&gt;
frameLoader-&gt;clientRedirected() -&gt;
FrameLoaderClientQt::dispatchWillPerformClientRedirect -&gt;

Which is not implemented. Would this be what is causing this?

I saw that Darin implemented that method for Mac. Darin do you have any idea to what is going on, or how I can implement this for Qt. What am I supposed to do in this method?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164646</commentid>
    <comment_count>3</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 12:02:06 -0800</bug_when>
    <thetext>This is being called by FrameLoader::requestFrame btw.

&gt; scheduleLocationChange -&gt;
&gt; schedule -&gt; 
&gt; startTimer (case ScheduledRedirection::redirection:) -&gt;
&gt; frameLoader-&gt;clientRedirected() -&gt;
&gt; FrameLoaderClientQt::dispatchWillPerformClientRedirect -&gt;

Which after all the above will call 

frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164648</commentid>
    <comment_count>4</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 12:08:30 -0800</bug_when>
    <thetext>So apparently the replaceDocument is the culprit, that maybe somehow removes the layoutTestController that we added in DRT::initJSObjects.

79     // FIXME: We should always replace the document, but doing so
80     //        synchronously can cause crashes:
81     //        http://bugs.webkit.org/show_bug.cgi?id=16782
82     if (replaceDocument)·
83         m_frame-&gt;loader()-&gt;replaceDocument(scriptResult);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164662</commentid>
    <comment_count>5</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 12:29:17 -0800</bug_when>
    <thetext>the root of the cause is 

806 clear(resetScripting, resetScripting); in FrameLoader, called from FrameLoader::begin() (called from replaceDocument()).

Changing this to clear(false, resetScripting); makes Qt work.

The first argument is &quot;bool clearWindowProperties&quot;, so that is where the problem lies.

Now we just need to find the right fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164669</commentid>
    <comment_count>6</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 12:38:59 -0800</bug_when>
    <thetext>After clearning the window properties, we are calling our

void QWebFrame::addToJavaScriptWindowObject ( const QString &amp; name, QObject * object )

but apparently it is not succeeding in adding the properties?

We have the following code in the DRT:

void DumpRenderTree::initJSObjects()
{
    QWebFrame *frame = qobject_cast&lt;QWebFrame*&gt;(sender());
    Q_ASSERT(frame);
    frame-&gt;addToJavaScriptWindowObject(QLatin1String(&quot;layoutTestController&quot;), m_controller);
    frame-&gt;addToJavaScriptWindowObject(QLatin1String(&quot;eventSender&quot;), m_eventSender);
    frame-&gt;addToJavaScriptWindowObject(QLatin1String(&quot;textInputController&quot;), m_textInputController);
    frame-&gt;addToJavaScriptWindowObject(QLatin1String(&quot;GCController&quot;), m_gcController);
}

so I guess that the layoutTestController should have been exported, and it was in the other cases.

Any ideas?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164672</commentid>
    <comment_count>7</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-18 12:44:22 -0800</bug_when>
    <thetext>For reference this is out implementation of addToJavaScriptWindowObject.

Does anyone spot any obvious bug?

 446 void QWebFrame::addToJavaScriptWindowObject(const QString &amp;name, QObject *object, QScriptEngine::ValueOwnership ownership)
 447 {
 448     if (!page()-&gt;settings()-&gt;testAttribute(QWebSettings::JavascriptEnabled))
 449         return;
 450
 451     JSC::JSLock lock(JSC::SilenceAssertionsOnly);
 452     JSDOMWindow* window = toJSDOMWindow(d-&gt;frame, mainThreadNormalWorld());
 453     JSC::Bindings::RootObject* root = d-&gt;frame-&gt;script()-&gt;bindingRootObject();
 454     if (!window) {
 455         qDebug() &lt;&lt; &quot;Warning: couldn&apos;t get window object&quot;;
 456         return;
 457     }
 458
 459     JSC::ExecState* exec = window-&gt;globalExec();
 460
 461     JSC::JSObject* runtimeObject =
 462             JSC::Bindings::QtInstance::getQtInstance(object, root, ownership)-&gt;createRuntimeObject(exec);
 463
 464     JSC::PutPropertySlot slot;
 465     window-&gt;put(exec, JSC::Identifier(exec, (const UChar *) name.constData(), name.length()), runtimeObject, slot);
 466 }

It seems to get the window from the WebCore::Frame and then to add the properties (line 464-465).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165024</commentid>
    <comment_count>8</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-19 10:54:57 -0800</bug_when>
    <thetext>More info:

All the window-&gt;put(exec, JSC::Identifier(exec, (const UChar *)
name.constData(), name.length()), runtimeObject, slot); executed ends up in:

void JSObject::put(ExecState* exec, const Identifier&amp; propertyName, JSValue value, PutPropertySlot&amp; slot) {

...

    // Check if there are any setters or getters in the prototype chain
    JSValue prototype;
    for (JSObject* obj = this; !obj-&gt;structure()-&gt;hasGetterSetterProperties(); obj = asObject(prototype)) {
        prototype = obj-&gt;prototype();
        if (prototype.isNull()) {
            putDirectInternal(exec-&gt;globalData(), propertyName, value, 0, true, slot);
            return;
        }
    }
...
}

And end up in the return there. I have checked the propertyName, and they are are correct and the value is an object (checked with isObject()).

putDirectInternal is thus called. I&apos;m debugging that method right now, but I would like to know if if is the right thing to do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165027</commentid>
    <comment_count>9</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-19 11:07:48 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; putDirectInternal is thus called. I&apos;m debugging that method right now, but I
&gt; would like to know if if is the right thing to do.

in putDirectInternal, all gets to the end:

if (!specificFunction)
   return;
slot.setNewProperty(this, offset);

and slot.setNewProperty(this, offset); is executed (specificFunction is 0 in all cases).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165056</commentid>
    <comment_count>10</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-19 12:32:40 -0800</bug_when>
    <thetext>I looked at the clearWindowProperties again, and outcommenting 

windowShell-&gt;setWindow(m_frame-&gt;domWindow());

in ScriptController::clearWindowShell() make it work. so why?

I can confirm that windowShell-&gt;window() is different from m_frame-&gt;domWindow()

Actually one is a JSDOMWindow* and the other is a DOMWindow. Shouldn&apos;t we set a JSDOMWindow?

As a test (not knowing this code well) I tried:

windowShell-&gt;setWindow(toJSDOMWindow(m_frame, mainThreadCurrentWorld()));

and that actually worked.

So, now I need an expert to chime in :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165083</commentid>
    <comment_count>11</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-19 13:56:39 -0800</bug_when>
    <thetext>(In reply to comment #10)
&gt; I looked at the clearWindowProperties again, and outcommenting 
&gt; 
&gt; windowShell-&gt;setWindow(m_frame-&gt;domWindow());
&gt; 
&gt; in ScriptController::clearWindowShell() make it work. so why?
&gt; 
&gt; I can confirm that windowShell-&gt;window() is different from m_frame-&gt;domWindow()
&gt; 
&gt; Actually one is a JSDOMWindow* and the other is a DOMWindow. Shouldn&apos;t we set a
&gt; JSDOMWindow?
&gt; 
&gt; As a test (not knowing this code well) I tried:
&gt; 
&gt; windowShell-&gt;setWindow(toJSDOMWindow(m_frame, mainThreadCurrentWorld()));
&gt; 
&gt; and that actually worked.
&gt; 
&gt; So, now I need an expert to chime in :-)

Disregard this. When windowShell-&gt;setWindow(m_frame-&gt;domWindow()); is called a new JSDOMWindow is created and this is the window we get in addToJavaScriptWindowObject.

The above confirms that if we create a new one, it breaks, if we reuse the old one, it works. Nothing more than that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165326</commentid>
    <comment_count>12</comment_count>
    <who name="Gabor Loki">loki</who>
    <bug_when>2009-11-20 09:17:15 -0800</bug_when>
    <thetext>The root of the problem is that the QtInstance is destroyed before execution of main JS is finished.

The following backtrace is produced before cti_op_get_by_id_method_check is called for notifyDone().

backtrace:
#0  ~QtInstance (this=0x8159910) at ../../../WebCore/bridge/qt/qt_instance.cpp:93
#1  0xb697edbd in WTF::RefCounted&lt;JSC::Bindings::Instance&gt;::deref (this=0x8159914) at ../../../JavaScriptCore/wtf/RefCounted.h:109
#2  0xb69aa4de in WTF::RefPtr&lt;JSC::Bindings::Instance&gt;::operator= (this=0xb1e456ec, optr=0x0) at ../../../JavaScriptCore/wtf/RefPtr.h:132
#3  0xb69ab27c in JSC::RuntimeObjectImp::invalidate (this=0xb1e456c0) at ../../../WebCore/bridge/runtime_object.cpp:67
#4  0xb69b2c21 in JSC::Bindings::RootObject::invalidate (this=0x8159128) at ../../../WebCore/bridge/runtime_root.cpp:102
#5  0xb69893a5 in WebCore::ScriptController::clearScriptObjects (this=0x80f8f1c) at ../../../WebCore/bindings/js/ScriptController.cpp:437
#6  0xb6d76683 in WebCore::FrameLoader::clear (this=0x80f8cac, clearWindowProperties=true, clearScriptObjects=true, clearFrameView=true) at ../../../WebCore/loader/FrameLoader.cpp:723
#7  0xb6d76f99 in WebCore::FrameLoader::begin (this=0x80f8cac, url=@0x80f8dbc, dispatch=true, origin=0x810b460) at ../../../WebCore/loader/FrameLoader.cpp:803
#8  0xb6d77b82 in WebCore::FrameLoader::replaceDocument (this=0x80f8cac, html=@0xbfb717cc) at ../../../WebCore/loader/FrameLoader.cpp:678
#9  0xb699f599 in WebCore::ScriptController::executeIfJavaScriptURL (this=0x80f8f1c, url=@0xbfb71888, userGesture=false, replaceDocument=true) at ../../../WebCore/bindings/ScriptControllerBase.cpp:83
#10 0xb6d8448d in WebCore::FrameLoader::requestFrame (this=0x80ba994, ownerElement=0x80f8290, urlString=@0x80f82d0, frameName=@0x80f82d4) at ../../../WebCore/loader/FrameLoader.cpp:371

If the Instance is destroyed, we will not able to do the lookup in JSC::RuntimeObjectImp::getOwnPropertySlot.

So, we should do something similar in bool FrameLoader::requestFrame what we did for bool FrameLoader::requestFrame.

-    if (!scriptURL.isEmpty())
-        frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL);
+    if (!scriptURL.isEmpty()) {
+        m_isExecutingJavaScriptFormAction = true;
+        frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL, false, false);
+        m_isExecutingJavaScriptFormAction = false;
+    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165327</commentid>
    <comment_count>13</comment_count>
    <who name="Gabor Loki">loki</who>
    <bug_when>2009-11-20 09:19:42 -0800</bug_when>
    <thetext>(In reply to comment #12)
&gt; what we did for bool FrameLoader::requestFrame.
Err, FrameLoader::submitForm</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165332</commentid>
    <comment_count>14</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-20 09:30:08 -0800</bug_when>
    <thetext>So it seems that

16 setTimeout(function ()
17 {
18     test();
19     if (window.layoutTestController)
20         layoutTestController.notifyDone();
21
22 }, 0);

is execute on the old DOMWindow, which is being replaced by test() (frameElement.src = ). Right loki?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165555</commentid>
    <comment_count>15</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-11-20 19:35:00 -0800</bug_when>
    <thetext>@keneth, nice investigation.
@gabor, good catch.
@andras, this is the exactly root of the CONSOLE MESSAGE error we were seeing ...

(In reply to comment #12)
&gt; The root of the problem is that the QtInstance is destroyed before execution of
&gt; main JS is finished.
&gt; 
&gt; The following backtrace is produced before cti_op_get_by_id_method_check is
&gt; called for notifyDone().
&gt; 
&gt; backtrace:
&gt; #0  ~QtInstance (this=0x8159910) at
&gt; ../../../WebCore/bridge/qt/qt_instance.cpp:93
&gt; #1  0xb697edbd in WTF::RefCounted&lt;JSC::Bindings::Instance&gt;::deref
&gt; (this=0x8159914) at ../../../JavaScriptCore/wtf/RefCounted.h:109
&gt; #2  0xb69aa4de in WTF::RefPtr&lt;JSC::Bindings::Instance&gt;::operator=
&gt; (this=0xb1e456ec, optr=0x0) at ../../../JavaScriptCore/wtf/RefPtr.h:132
&gt; #3  0xb69ab27c in JSC::RuntimeObjectImp::invalidate (this=0xb1e456c0) at
&gt; ../../../WebCore/bridge/runtime_object.cpp:67
&gt; #4  0xb69b2c21 in JSC::Bindings::RootObject::invalidate (this=0x8159128) at
&gt; ../../../WebCore/bridge/runtime_root.cpp:102
&gt; #5  0xb69893a5 in WebCore::ScriptController::clearScriptObjects
&gt; (this=0x80f8f1c) at ../../../WebCore/bindings/js/ScriptController.cpp:437
&gt; #6  0xb6d76683 in WebCore::FrameLoader::clear (this=0x80f8cac,
&gt; clearWindowProperties=true, clearScriptObjects=true, clearFrameView=true) at
&gt; ../../../WebCore/loader/FrameLoader.cpp:723
&gt; #7  0xb6d76f99 in WebCore::FrameLoader::begin (this=0x80f8cac, url=@0x80f8dbc,
&gt; dispatch=true, origin=0x810b460) at ../../../WebCore/loader/FrameLoader.cpp:803
&gt; #8  0xb6d77b82 in WebCore::FrameLoader::replaceDocument (this=0x80f8cac,
&gt; html=@0xbfb717cc) at ../../../WebCore/loader/FrameLoader.cpp:678
&gt; #9  0xb699f599 in WebCore::ScriptController::executeIfJavaScriptURL
&gt; (this=0x80f8f1c, url=@0xbfb71888, userGesture=false, replaceDocument=true) at
&gt; ../../../WebCore/bindings/ScriptControllerBase.cpp:83
&gt; #10 0xb6d8448d in WebCore::FrameLoader::requestFrame (this=0x80ba994,
&gt; ownerElement=0x80f8290, urlString=@0x80f82d0, frameName=@0x80f82d4) at
&gt; ../../../WebCore/loader/FrameLoader.cpp:371
&gt; 
&gt; If the Instance is destroyed, we will not able to do the lookup in
&gt; JSC::RuntimeObjectImp::getOwnPropertySlot.
&gt; 
&gt; So, we should do something similar in bool FrameLoader::requestFrame what we
&gt; did for bool FrameLoader::requestFrame.
&gt; 
&gt; -    if (!scriptURL.isEmpty())
&gt; -        frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL);
&gt; +    if (!scriptURL.isEmpty()) {
&gt; +        m_isExecutingJavaScriptFormAction = true;
&gt; +        frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL, false, false);
&gt; +        m_isExecutingJavaScriptFormAction = false;
&gt; +    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>166026</commentid>
    <comment_count>16</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2009-11-24 02:54:27 -0800</bug_when>
    <thetext>(In reply to comment #12)
&gt; The root of the problem is that the QtInstance is destroyed before execution of
&gt; main JS is finished.
&gt; So, we should do something similar in bool FrameLoader::requestFrame what we
&gt; did for bool FrameLoader::requestFrame.
&gt; 
&gt; -    if (!scriptURL.isEmpty())
&gt; -        frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL);
&gt; +    if (!scriptURL.isEmpty()) {
&gt; +        m_isExecutingJavaScriptFormAction = true;
&gt; +        frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL, false, false);
&gt; +        m_isExecutingJavaScriptFormAction = false;
&gt; +    }

Actually the problem is a bit bigger than this. Adding the

frame-&gt;script()-&gt;executeIfJavaScriptURL(scriptURL, false, false);

instead, will just make it not replace the frame at all, meaning that the test would break. The right behaviour is to replace the frame, but the thing is that since we are doing that from javascript, we loose the context from where we are executing it, as I believe it is tied to the frame.

I guess the right fix would be to not destroy that context until we are finished executing javascript, but how to find out that is probably a bit complicated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168387</commentid>
    <comment_count>17</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2009-12-03 06:32:54 -0800</bug_when>
    <thetext>Involved failing tests skipped in r51635.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>174792</commentid>
    <comment_count>18</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2009-12-24 11:32:30 -0800</bug_when>
    <thetext>(In reply to comment #17)
&gt; Involved failing tests skipped in r51635.

Also affects:

fast/events/pageshow-pagehide-on-back-cached-with-frames.html
fast/events/pageshow-pagehide-on-back-cached.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>174966</commentid>
    <comment_count>19</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2009-12-26 12:31:26 -0800</bug_when>
    <thetext>This looks like a slightly related one:

LayoutTests/http/tests/misc/set-window-opener-to-null.html

It fails at:

  if (window.layoutTestController) {
    child_window_opened = layoutTestController.globalFlag;

That is, window.layoutTestController.globalFlag remains false but w.layoutTestController.globalFlag is true (opening http://127.0.0.1:8000/misc/resources/content-iframe.html sets it to true). Changing the above lines to:

  if (w.layoutTestController) {
    child_window_opened = w.layoutTestController.globalFlag;

allows the test to pass.



Full text of test below:

--
&lt;html&gt;
&lt;script&gt;
if (window.layoutTestController) {
  layoutTestController.setCanOpenWindows();
  layoutTestController.dumpAsText();
  layoutTestController.waitUntilDone();
  layoutTestController.globalFlag = false;
}

var w = window.open(&quot;http://127.0.0.1:8000/misc/resources/content-iframe.html&quot;);
w.opener = null;

function wait_to_start() {
  var child_window_opened;

  // polling layoutTestController.globalFlag or w.document
  if (window.layoutTestController) {
    child_window_opened = layoutTestController.globalFlag;
  } else {
    // polling w.document is not very reliable cross browsers,
    // it works in chrome for manual testsing.
    // We might want to change it to using postMessage when it
    // is supported.
    child_window_opened = !w.document;
  }

  if (!child_window_opened) {
    setTimeout(wait_to_start, 30);
    return;
  }

  var e = document.getElementById(&apos;console&apos;);
  e.innerHTML = w.opener == null ? &apos;PASS&apos; : &apos;FAIL&apos;;

  w.close();

  if (window.layoutTestController)
    layoutTestController.notifyDone();
}

window.onload = wait_to_start;

&lt;/script&gt;
&lt;body&gt;
This tests that following code works in Chrome:
&lt;pre&gt;
var w = window.open(...);
w.opener = null;
&lt;/pre&gt;
After new page finishes loading, its opener should stay as null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>235945</commentid>
    <comment_count>20</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2010-06-09 12:43:49 -0700</bug_when>
    <thetext>There is a potential solution to this bug posted for review at:

https://bugs.webkit.org/show_bug.cgi?id=37725

Both bugs are caused by the fact that ScriptController currently destroys a page&apos;s Qt bindings objects when navigating away from it. The solution proposed is to make a special case for such objects by tracking them in a root object that persists between navigations within a frame and only gets destroyed with the frame.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>237304</commentid>
    <comment_count>21</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2010-06-12 10:06:18 -0700</bug_when>
    <thetext>The affected test was fixed by http://trac.webkit.org/changeset/61062

OK to close?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>237322</commentid>
    <comment_count>22</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2010-06-12 11:26:34 -0700</bug_when>
    <thetext>Thanks Robert</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>239312</commentid>
    <comment_count>23</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2010-06-17 02:59:06 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 37725 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>