michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that the onmozbrowsertitlechange event works. michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: function runTest() { michael@0: var iframe1 = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe1).mozbrowser = true; michael@0: document.body.appendChild(iframe1); michael@0: michael@0: // iframe2 is a red herring; we modify its title but don't listen for michael@0: // titlechanges; we want to make sure that its titlechange events aren't michael@0: // picked up by the listener on iframe1. michael@0: var iframe2 = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe2).mozbrowser = true; michael@0: document.body.appendChild(iframe2); michael@0: michael@0: // iframe3 is another red herring. It's not a mozbrowser, so we shouldn't michael@0: // get any titlechange events on it. michael@0: var iframe3 = document.createElement('iframe'); michael@0: document.body.appendChild(iframe3); michael@0: michael@0: var numTitleChanges = 0; michael@0: michael@0: iframe1.addEventListener('mozbrowsertitlechange', function(e) { michael@0: // Ignore empty titles; these come from about:blank. michael@0: if (e.detail == '') michael@0: return; michael@0: michael@0: numTitleChanges++; michael@0: michael@0: if (numTitleChanges == 1) { michael@0: is(e.detail, 'Title'); michael@0: SpecialPowers.getBrowserFrameMessageManager(iframe1) michael@0: .loadFrameScript("data:,content.document.title='New title';", michael@0: /* allowDelayedLoad = */ false); michael@0: SpecialPowers.getBrowserFrameMessageManager(iframe2) michael@0: .loadFrameScript("data:,content.document.title='BAD TITLE 2';", michael@0: /* allowDelayedLoad = */ false); michael@0: } michael@0: else if (numTitleChanges == 2) { michael@0: is(e.detail, 'New title'); michael@0: iframe1.src = 'data:text/html,