How to simulate custom API through chrome extension

88 views
Skip to first unread message

rinkygu...@gmail.com

unread,
Feb 15, 2016, 11:54:07 PM2/15/16
to Google Chrome Developer Tools
Hi ,

I have created a chrome extension with new panel and created some required UI. I want to simulate my API behavior through overriding of values. like geolocation emulation feature.
i have mentioned my API in manifiest.json to bundle with extension.

 "content_scripts": [{
    "matches": ["<all_urls>"],
    "js": ["customAPI.js","content_script.js"]
}]

when i trying to override function through   --    chrome.devtools.inspectedWindow.eval
Its not working.

please help me out , how i can do this.

Thanks.

PhistucK

unread,
Feb 16, 2016, 1:56:26 AM2/16/16
to Google Chrome Developer Tools
Do you see any console error?


PhistucK

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/dcc5ca69-7182-454b-aef7-85a27bb8a35f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rinkygu...@gmail.com

unread,
Feb 16, 2016, 6:00:25 AM2/16/16
to Google Chrome Developer Tools
I am new to chrome extension development.

Here is my code to simulate geolocation . I am launching app http://html5demos.com/geo

chrome.devtools.inspectedWindow.eval("setRedSelectedElement($0)",
function(s,e){
alert ("execute me");
navigator.geolocation.getCurrentPosition = function(successCallback, errorCallback) {
   successCallback({coords:{lattitude:26.44976, longitude:74.64116}});
}
});

I am getting "execute me"alert message.
after that nothig is executing.

how i can override javascript to simulate my expected behavior. 
Please reply



On Tuesday, 16 February 2016 12:26:26 UTC+5:30, PhistucK wrote:
Do you see any console error?


PhistucK

On Tue, Feb 16, 2016 at 6:54 AM, <rinkygu...@gmail.com> wrote:
Hi ,

I have created a chrome extension with new panel and created some required UI. I want to simulate my API behavior through overriding of values. like geolocation emulation feature.
i have mentioned my API in manifiest.json to bundle with extension.

 "content_scripts": [{
    "matches": ["<all_urls>"],
    "js": ["customAPI.js","content_script.js"]
}]

when i trying to override function through   --    chrome.devtools.inspectedWindow.eval
Its not working.

please help me out , how i can do this.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

PhistucK

unread,
Feb 16, 2016, 6:58:20 AM2/16/16
to Google Chrome Developer Tools
What do you by "nothig is executing"? The specific code you showed is not supposed to do anything other than alerting the user and overriding a function. If it alerts, it definitely executes.

Regarding the page itself, it tries to run getCurrentPosition immediately and you did not specify "run_at": "document_start" in the content script in the manifest, so it probably runs too late.

Anyway, for extension development questions and issues, use stackoverflow.com.


PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/2a6e102c-a550-4db2-9cc3-8a3776a0fd14%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages