Tag: 谷歌浏览器

Chrome扩展程序消息传递:未发送响应

我正试图在内容脚本和扩展之间传递消息 这是我在内容脚本中的内容 chrome.runtime.sendMessage({type: "getUrls"}, function(response) { console.log(response) }); 并在我的背景脚本 chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { if (request.type == "getUrls"){ getUrls(request, sender, sendResponse) } }); function getUrls(request, sender, sendResponse){ var resp = sendResponse; $.ajax({ url: "http://localhost:3000/urls", method: 'GET', success: function(d){ resp({urls: d}) } }); } 现在,如果我在getUrls函数的ajax调用之前发送响应,响应发送成功,但是在发送响应的时候ajax调用的成功方法没有发送,当我进入debugging时,我可以看到该端口在sendResponse函数的代码内是空的。

如何testingChrome扩展?

有没有一个好的方法来做到这一点? 我正在编写一个扩展,作为内容脚本与网站交互,并使用localstorage保存数据。 有什么工具,框架等,我可以用来testing这种行为? 我意识到有一些testingJavaScript的通用工具,但那些足够的能力来testing扩展? unit testing是最重要的,但我也对其他types的testing感兴趣(如集成testing)。

Chromedebugging – 打开下一个点击事件

我们有一个button。 点击事件是由第三方框架来处理的,但是,框架却是有问题的。 我们要debugging框架,但是,我们不知道相应的事件处理程序代码驻留在哪里以设置断点。 如何一般地“打破下一个点击事件”,看看这个点击是由第三方框架处理的?

资源解释为文档,但使用MIMEtypes的应用程序/ zip传输

使用Chrome 12.0.742.112,如果我使用以下标题redirect: HTTP/1.1 302 Found Location: http://0.0.0.0:3000/files/download.zip Content-Type: text/html; charset=utf-8 Cache-Control: no-cache X-Ua-Compatible: IE=Edge X-Runtime: 0.157964 Content-Length: 0 Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) Date: Tue, 05 Jul 2011 18:42:25 GMT Connection: Keep-Alive 如果遵循则返回以下标题: HTTP/1.1 200 OK Last-Modified: Tue, 05 Jul 2011 18:18:30 GMT Content-Type: application/zip Content-Length: 150014 Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) Date: Tue, 05 Jul 2011 18:44:47 GMT […]

谷歌铬扩展:: console.log()从后台页面?

如果我打电话给console.log('something'); 从popup页面,或包括任何脚本,它工作正常。 但是,由于背景页面不是直接从popup页面运行,所以不包含在控制台中。 有没有办法,我可以得到console.log()在后台页面显示在控制台的popup页面? 有没有办法从背景页面调用popup页面中的一个函数?

console.log中的时间戳在Chrome中?

是否有任何快速的方式让Chrome浏览器输出console.log写入时间戳(就像Firefox一样)。 或者是预先添加new Date().getTime()唯一的select?

如何在Google Chrome中一步移除所有断点?

如何在Google Chrome中一步移除所有断点? 使用版本11。 [更新] 现在有一个function请求这个。 [更新] function要求已closures(2011年12月)!

未捕获的SyntaxError:意外的标记:

我在我的MooTools脚本中运行AJAX调用,这在Firefox中正常工作,但在Chrome中我得到一个Uncaught SyntaxError: Unexpected token :错误,我无法确定为什么。 注释掉代码以确定错误代码在什么地方什么都不产生,我想这可能是JSON返回的问题。 检查控制台我看到返回的JSON是这样的: {"votes":47,"totalvotes":90} 我没有看到任何问题,为什么会出现这个错误? vote.each(function(e){ e.set('send', { onRequest : function(){ spinner.show(); }, onComplete : function(){ spinner.hide(); }, onSuccess : function(resp){ var j = JSON.decode(resp); if (!j) return false; var restaurant = e.getParent('.restaurant'); restaurant.getElements('.votes')[0].set('html', j.votes + " vote(s)"); $$('#restaurants .restaurant').pop().set('html', "Total Votes: " + j.totalvotes); buildRestaurantGraphs(); } }); e.addEvent('submit', function(e){ e.stop(); […]

Chrome未捕获的语法错误:非预期的令牌非法

可能重复: SyntaxError:意外的标记ILLEGAL Chrome尝试加载页面上的脚本文件时收到主题错误。 它说这是在JavaScript文件的最后一行。 我似乎无法find任何问题。 在Firefox中没有错误,脚本按预期工作。 只需使用表单validation // JavaScript Document $(function() { $('#wm-form').submit(function() { var errors = false; var errorMsg = ""; $('.required').each(function() { if(!validField($(this))) { errorMsg += $(this).attr('name').capitalize() + " cannot be blank\n"; errors = true; } }); var emailAddress = $('#email'); if(isValid(emailAddress) && !(/^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$/.test(emailAddress.val()))) { errorMsg += "Not a valid email address. Please […]

Chrome开发工具:如何跟踪networking的链接,打开一个新的标签?

我想跟踪点击链接时发生的networking活动。 问题是,链接打开一个新的标签,显然开发工具每个标签打开。 “保留日志导航”不起作用。 我目前的解决scheme是转移到没有这个问题的FireFox和HttpFox。 我想知道所有的Chrome开发人员如何pipe理,这听起来很基本(当然,我已经find了答案,没有发现任何有用的东西)。