New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 836561 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Need an interface to get coordinate from DOM.Node

Reported by zhenjun....@gmail.com, Apr 25 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

Steps to reproduce the problem:
1. Attach chrome.debugger in chrome extension
2. Get document by DOM.getDocument interface and locate one element with DOM.querySelector
3. DOM.querySelector will response one nodeID of the Dom tree
4. Need one way/interface to get the coordinate based on this nodeID, like the function in javascript: getBoundingClientRect();

What is the expected behavior?
Expect one way to get more information of one Dom node.

What went wrong?
Cannot get coordinate of one node.

Did this work before? N/A 

Chrome version: 65.0.3325.181  Channel: n/a
OS Version: ubuntu 16.04
Flash Version:
 
Labels: Needs-Triage-M65
Cc: vamshi.kommuri@chromium.org
Labels: Triaged-ET Needs-Feedback
Thanks for filing the issue!

@Reporter: Could you please share a sample test file/extension which helps us to triage the issue in a better way. Any further inputs from your end may be helpful.

Comment 3 Deleted

Project Member

Comment 4 by sheriffbot@chromium.org, Apr 26 2018

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
@vamshi.kommuri, thanks for your response.

Here are my codes calling DOM.getDocument in background.js:

var tab_id = 2;
chrome.debugger.attach({tabId: tab_id}, "1.3", onAttach.bind(null, tab_id));
chrome.debugger.sendCommand({tabId: tab_id}, 'Page.enable');
chrome.debugger.sendCommand({tabId: tab_id},
                            'DOM.getDocument', {"depth": -1, "pierce": true},
                            function(response) {
                                console.log('DOM.getDocument: ', response);
                                handleDOMTree(response.root);
                            });

With these codes in the extension, when you open one page in your browser,  handleDOMTree callback function will be called.
In handleDOMTree, we can try to query DOM node by css selector, here is an example:

function handleDOMTree(n) {
    var body = n;
    for(var j = 0 ; j < n.childNodeCount; j ++){
        if (n.children[j].localName == "body"){
            // found body
            body = n.children[j];
        }
    }
    chrome.debugger.sendCommand({tabId: tab_id}, 'DOM.querySelector', {
        "nodeId": body.nodeId,
        "selector": ".tid-summary-navi-tab-header a"   // replace it to an valid css selector on your page
    }, function(response) {
        var nodeId = response.nodeId;
        console.log("Got node : ", response);                               // Need a way to get coordinate with nodeId here
    });
}
Any idea about it? I want to get coordinate based on a DOM.Node from debugger interface.
Cc: krajshree@chromium.org
Labels: Needs-Feedback
Reporter@ - As per comment #4, please provide a sample test file/extension zip file to test the issue from TE-end.
This will help us in triaging the issue further.

Thanks...!!
Status: WontFix (was: Unconfirmed)
I think DOM.getBoxModel should work for you. Thanks for filing an issue!
@dgozman, thanks, I can get the element rect and click it now.

Sign in to add a comment