Ticket #36 (new defect)

Opened 1 year ago

Last modified 6 months ago

GreaseMonkey won't run in hidden iframes

Reported by: mjk49..@yahoo.com Assigned to:
Priority: major Milestone:
Version: Keywords:
Cc:

Description

If a page contains an Iframe that is not displayed and that iframe loads content that should cause a GreaseMonkey? script to execute, the script will not run. It will only run on visible Iframes.

The attached files demonstrate the problem. Install the script which just adds text to the bottom of all pages. Then open the test.html file. This contains 2 iframes: one visible and one hidden. A tab panel at the top of the page is used to "switch" between them. 2 links at the top of the page will load www.google.com in the specified "tab" (iframe). The iframes have an onload function which will display that iframe and hide the other when a page loads.

Tests:

1. With tab 1 displayed click load google in tab 2. This will load http://www.google.com in the hidden iframe "Tab2pane" and then display it.

2. With tab 2 displayed click load google in tab 2.

Expected results:

Both should display the text "Grease Monkey ran on this page".

Actual results:

Only test #2 displays the text. Greasemonkey never executed on the hidden iframe.

Attachments

test.html (2.5 kB) - added by mjk49..@yahoo.com on 07/24/07 12:59:09.
Test HTML file containing hidden iframes
testscript.user.js (315 bytes) - added by mjk49..@yahoo.com on 07/24/07 13:01:16.
Test GM script to put text on bottom of every page

Change History

07/24/07 12:59:09 changed by mjk49..@yahoo.com

  • attachment test.html added.

Test HTML file containing hidden iframes

07/24/07 13:01:16 changed by mjk49..@yahoo.com

  • attachment testscript.user.js added.

Test GM script to put text on bottom of every page

07/24/07 13:44:01 changed by aranti..@gmail.com

Your issue seems valid, but your test case is unnecessarily complex. It just takes a few lines of simple HTML:

<html><body>
<iframe src='http://www.google.com/'></iframe>
<hr>
<iframe src='http://www.google.com/' style='display:none;'></iframe>
</body></html>

And one line of .user.js:

alert('GreaseMonkey Ran!');

To see this happening.

Unfortunately, my intuition tells me that Firefox is simply not generating a DOMContentLoaded event. I'll check to see if that's really the case.

07/25/07 17:52:37 changed by aranti..@gmail.com

  • cc set to aranti..@gmail.com.

07/25/07 18:45:51 changed by aranti..@gmail.com

  • cc deleted.

Confirmed. No DOMContentLoaded event is fired on an iframe that is "display:none". This event is how Greasemonkey knows there is a new page ready to be greased. Without it, there isn't much we can do.

I've checked, and we don't get a regular "load" event, either. This must be intentional, but I don't know for sure, or if so why.

I'd suggest following up with support about mozilla, why these events are not bubbled upwards in this case.

07/26/07 10:09:57 changed by mjk49..@yahoo.com

Okay, I'll open up a bug with Firefox.

Thank you.

07/26/07 11:07:41 changed by mjk49..@yahoo.com

I found that the following works, which is done with just scripting and not using Grease Monkey. Any idea why that works Grease Monkey does not?

Replacing "load" with "DOMContentLoaded" doesn't work, but I'm not sure I'm attaching the event to the correct element.

I noticed that GM listens for the "DOMContenetLoaded" event on the appcontent element, is that what should be firing when an iframe loads?

I'm trying to write up a bug report for Mozilla without specifying that the problem only occurs in Grease Monkey so I want to put together something that doesn't use GM.

<html><body>
<iframe id="frame1" src='http://www.google.com/'></iframe>
<hr>
<iframe id="frame2" src='http://www.google.com/' style='display:none;'></iframe>

<script language="javascript">
var frame1 = document.getElementById("frame1");
var frame2 = document.getElementById("frame1");

function listener1() {
  alert("frame 1 loaded");
}

function listener2() {
  alert("frame 2 loaded");
}
	
frame1.addEventListener('load', listener1, false);
frame2.addEventListener('load', listener2, false);
</script>
</body></html>

07/26/07 11:24:11 changed by aranti..@gmail.com

Take a look at: http://developer.mozilla.org/en/docs/Code_snippets:On_page_load

It does not fire the load event for hidden iframes. If you want to test this, userChrome.js is probably the easiest path.

Feel free to try the same code with the "DOMContentLoaded" event, too.

07/26/07 12:42:29 changed by boo..@youngpup.net

Maybe there is something that we can do that will make this work. Let's leave the bug open for investigation.

07/26/07 13:22:58 changed by mjk49..@yahoo.com

Well in the meantime I opened a bug against Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=389702

If they fix it great, if they reject it...

08/14/07 18:16:11 changed by anonymous

12/22/07 15:50:01 changed by thalam..@hotmail.com

It's my understanding that a hidden object shouldn't receive/send any events to protect the user from unwarranted attacks. The last thing I would need is a foreign script trying to gather intel on my surfing habits (outside of the headers of course). Anywhoo...that's my understanding.

04/01/08 01:30:25 changed by anonymous

江苏大洋冷却塔有限公司是集冷却塔研发、设计、制造、安装维修为一体的科研型经济实体。公司位于江南水乡溧阳市平陵西路288号,交通便捷,人文荟萃。

主产品"大正"牌冷却塔在2004年荣获"中国市场首选放心品牌","全国用户产品质量满意、售后服务满意示范单位"。连续五年被评为"重合同、守信用"企业,连续多年被企业信用等级评定委员会评定为"AAA"级,企业通过了中联认证中心"ISO9001:2000的质量管理体系认证"以及"ISO14001:1996环境管理体系认证"。被江苏市场产品质量监督调查办公室、江苏名牌企业促进会,江苏3.15维权投诉监督跟踪调查办公室授予"江苏市场公认名牌产品"、"质量·信誉"先进单位。在今后的发展中,本公司将一如既往,以严谨的质量保证模式来满足用户的需求。 江苏大洋冷却塔有限公司积几十年生产实践经验,形成了GNZF-500~4500型、HLT-500~4500型、NH-500~4500型、HH-500~4500型等多个品种的冷却塔产品,产品远销东南亚各国。在企业的发展过程中,公司员工牢固树立"凝聚、务实、诚信、进取"的总方针,建立了严密的新产品开发操作程序,严格的管理制度和严谨的质量保证体系。公司拥有一支素质良好的员工队伍,尤其在玻璃钢成型工艺,钢结构的防腐处理,塑料加工工艺等方面已形成了独特、稳定、可靠的工艺流程和加工方法。

04/08/08 23:50:29 changed by anonymous

电子地磅解码器,吨位遥控器/本吨位遥控器引进日本先进技术研制而成,完全采用数字式集成电路技术,采用万能解码数据处理线路,适用于10----150吨以下吨位,无须对地磅作任何改动 具有防拦截,防扫描等优点,解码器安装于车上或离地磅8米以内,在电子称旁40米或60米以内,能控制电子称的数码数据,最小值20公斤,规格10 /15/20,此产品主要产生电子磁场干扰和控制,从而使吨位变大或变小,性能稳定可靠,体积小,遥控主机 解码处理器 如烟盒大小,遥控器配两种型号,隐蔽性强,附件含使用光盘一套,

04/19/08 08:58:18 changed by anonymous


Add/Change #36 (GreaseMonkey won't run in hidden iframes)