예제 #1
0
static string toStr(WKBundlePageRef page, WKBundleScriptWorldRef world, WKBundleRangeHandleRef rangeRef)
{
    if (!rangeRef)
        return "(null)";

    WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);

    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world);
    JSValueRef rangeValue = WKBundleFrameGetJavaScriptWrapperForRangeForWorld(frame, rangeRef, world);
    ASSERT(JSValueIsObject(context, rangeValue));
    JSObjectRef rangeObject = (JSObjectRef)rangeValue;

    JSValueRef startNodeValue = propertyValue(context, rangeObject, "startContainer");
    ASSERT(JSValueIsObject(context, startNodeValue));
    JSObjectRef startNodeObject = (JSObjectRef)startNodeValue;

    JSValueRef endNodeValue = propertyValue(context, rangeObject, "endContainer");
    ASSERT(JSValueIsObject(context, endNodeValue));
    JSObjectRef endNodeObject = (JSObjectRef)endNodeValue;

    int startOffset = propertyValueInt(context, rangeObject, "startOffset");
    int endOffset = propertyValueInt(context, rangeObject, "endOffset");

    ostringstream out;
    out << "range from " << startOffset << " of " << dumpPath(context, startNodeObject) << " to " << endOffset << " of " << dumpPath(context, endNodeObject);
    return out.str();
}
예제 #2
0
void QtBuiltinBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
{
    if (!WKBundleFrameIsMainFrame(frame) || WKBundleScriptWorldNormalWorld() != world)
        return;
    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world);
    registerNavigatorQtObject(context);
}
예제 #3
0
static void
didClearWindowObjectForFrame (WKBundlePageRef page, 
                              WKBundleFrameRef frame, 
                              WKBundleScriptWorldRef scriptWorld, 
                              const void *data) 
{
    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, scriptWorld);
    gobred_bridge_setup (context);
}
예제 #4
0
void QtBuiltinBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
{
    if (!WKBundleFrameIsMainFrame(frame) || WKBundleScriptWorldNormalWorld() != world)
        return;
    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world);
    registerNavigatorQtObject(context);
#ifdef HAVE_WEBCHANNEL
    registerNavigatorQtWebChannelTransportObject(context);
#endif
}
예제 #5
0
static string dumpPath(WKBundlePageRef page, WKBundleScriptWorldRef world, WKBundleNodeHandleRef node)
{
    if (!node)
        return "(null)";

    WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);

    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world);
    JSValueRef nodeValue = WKBundleFrameGetJavaScriptWrapperForNodeForWorld(frame, node, world);
    ASSERT(JSValueIsObject(context, nodeValue));
    JSObjectRef nodeObject = (JSObjectRef)nodeValue;

    return dumpPath(context, nodeObject);
}
예제 #6
0
void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
{
    if (!InjectedBundle::shared().isTestRunning())
        return;

    if (WKBundleScriptWorldNormalWorld() != world)
        return;

    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world);
    JSObjectRef window = JSContextGetGlobalObject(context);

    JSValueRef exception = 0;
    InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception);
    InjectedBundle::shared().gcController()->makeWindowObject(context, window, &exception);
    InjectedBundle::shared().eventSendingController()->makeWindowObject(context, window, &exception);
}
예제 #7
0
void LayoutTestController::evaluateScriptInIsolatedWorld(JSContextRef context, unsigned worldID, JSStringRef script)
{
    // A worldID of 0 always corresponds to a new world. Any other worldID corresponds to a world
    // that is created once and cached forever.
    WKRetainPtr<WKBundleScriptWorldRef> world;
    if (!worldID)
        world.adopt(WKBundleScriptWorldCreateWorld());
    else {
        WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).first->second;
        if (!worldSlot)
            worldSlot.adopt(WKBundleScriptWorldCreateWorld());
        world = worldSlot;
    }

    WKBundleFrameRef frame = WKBundleFrameForJavaScriptContext(context);
    if (!frame)
        frame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());

    JSGlobalContextRef jsContext = WKBundleFrameGetJavaScriptContextForWorld(frame, world.get());
    JSEvaluateScript(jsContext, script, 0, 0, 0, 0); 
}
예제 #8
0
 nullptr, // didFailProvisionalLoadWithErrorForFrame
 nullptr, // didCommitLoadForFrame
 nullptr, // didFinishDocumentLoadForFrame
 nullptr, // didFinishLoadForFrame
 nullptr, // didFailLoadWithErrorForFrame
 nullptr, // didSameDocumentNavigationForFrame
 nullptr, // didReceiveTitleForFrame
 nullptr, // didFirstLayoutForFrame
 nullptr, // didFirstVisuallyNonEmptyLayoutForFrame
 nullptr, // didRemoveFrameFromHierarchy
 nullptr, // didDisplayInsecureContentForFrame
 nullptr, // didRunInsecureContentForFrame
 // didClearWindowObjectForFrame
 [](WKBundlePageRef, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void*) {
     fprintf(stderr, "didClearWindowObjectForFrame\n");
     JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, scriptWorld);
     injectJSExtensions(context);
 },
 nullptr, // didCancelClientRedirectForFrame
 nullptr, // willPerformClientRedirectForFrame
 nullptr, // didHandleOnloadEventsForFrame
 nullptr, // didLayoutForFrame
 nullptr, // didNewFirstVisuallyNonEmptyLayout_unavailable
 nullptr, // didDetectXSSForFrame
 nullptr, // shouldGoToBackForwardListItem
 nullptr, // globalObjectIsAvailableForFrame
 nullptr, // willDisconnectDOMWindowExtensionFromGlobalObject
 nullptr, // didReconnectDOMWindowExtensionToGlobalObject
 nullptr, // willDestroyGlobalObjectForDOMWindowExtension
 nullptr, // didFinishProgress
 nullptr, // shouldForceUniversalAccessFromLocalURL