[Webkit-unassigned] [Bug 106811] New: Web Inspector: Add iframe option to inspectedWindow.eval() extension API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jan 14 10:57:13 PST 2013


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

           Summary: Web Inspector: Add iframe option to
                    inspectedWindow.eval() extension API
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: Web Inspector
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: johnjbarton at chromium.org
                CC: keishi at webkit.org, pmuellr at yahoo.com,
                    pfeldman at chromium.org, yurys at chromium.org,
                    apavlov at chromium.org, loislo at chromium.org,
                    vsevik at chromium.org,
                    web-inspector-bugs at googlegroups.com


The extension API function inspectedWindow.eval() allows tooling extensions to gather data from the web page, critical to many extensions. Currently extensions cannot access data from iframes however, limiting extensions to simple web pages.

By adding another option to the existing API, iframes can be supported. Here is example code from a test case. First we get the full URL from inspectedWindow.getResources:
var iframeSrc = document.querySelector('iframe').getAttribute('src');
    var url;
    webInspector.inspectedWindow.getResources(function(resources){
        resources.foreach(function(resource){
            if (resource.url.indexOf(iframeSrc) !== -1) {
                url = resource.url;
            }
        });
    });

Then we extract the origin:

    var segments = url.split('/'); // http://a.b.c:xxx/path
    var origin = segments[0] + '//' + segments[1];

And use these in the option to eval:
    var options = {
        frame: {
            url: url,
            securityOrigin: origin
        }
    }
    webInspector.inspectedWindow.eval("window.location.pathname", options, callbackAndNextTest(extension_onEval, nextTest));

contentScript contexts could be accessed using their securityOrigin.

Patch ready

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list