From 1165a8cfdd57412e9c41612c0cf69286efc53050 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 17 Sep 2013 15:23:43 +0200 Subject: [PATCH 01/43] Bug 917246 - Make the tree compile with --enable-pulse. r=jesup --HG-- extra : rebase_source : 9496c74dcc81cef40cf6e0f49b47c9c6c06a52d4 --- media/libcubeb/src/cubeb_pulse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/libcubeb/src/cubeb_pulse.c b/media/libcubeb/src/cubeb_pulse.c index 94c068e1f7f9..918651e6d3a2 100644 --- a/media/libcubeb/src/cubeb_pulse.c +++ b/media/libcubeb/src/cubeb_pulse.c @@ -584,7 +584,7 @@ pulse_stream_get_latency(cubeb_stream * stm, uint32_t * latency) return CUBEB_ERROR; } - *latency = (r_usec * stm->sample_spec.rate) / PR_NSEC_PER_SEC; + *latency = r_usec * stm->sample_spec.rate / PA_USEC_PER_SEC; return CUBEB_OK; } From 71dddda23bef64d625ac1241f4db76da6bd16164 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Mon, 26 Aug 2013 19:19:36 +0200 Subject: [PATCH 02/43] Bug 881959 - Mute WebAudio nodes that are part of a cycle that contains no DelayNode, and make cycles work. r=ehsan --HG-- extra : rebase_source : d4bc378128cf15f8d8395b45b4443ca6b06c5bd2 --- content/media/AudioNodeEngine.h | 3 +++ content/media/AudioNodeStream.cpp | 17 +++++++++++++++-- content/media/AudioNodeStream.h | 14 +++++++++++++- content/media/MediaStreamGraph.cpp | 24 ++++++++++++++++++++++++ content/media/webaudio/AudioNode.h | 4 ++++ content/media/webaudio/DelayNode.cpp | 5 +++++ content/media/webaudio/DelayNode.h | 5 +++++ 7 files changed, 69 insertions(+), 3 deletions(-) diff --git a/content/media/AudioNodeEngine.h b/content/media/AudioNodeEngine.h index ad51fc87d473..346bb148f3f9 100644 --- a/content/media/AudioNodeEngine.h +++ b/content/media/AudioNodeEngine.h @@ -15,6 +15,7 @@ namespace mozilla { namespace dom { struct ThreeDPoint; class AudioParamTimeline; +class DelayNodeEngine; } class AudioNodeStream; @@ -206,6 +207,8 @@ public: MOZ_COUNT_DTOR(AudioNodeEngine); } + virtual dom::DelayNodeEngine* AsDelayNodeEngine() { return nullptr; } + virtual void SetStreamTimeParameter(uint32_t aIndex, TrackTicks aParam) { NS_ERROR("Invalid SetStreamTimeParameter index"); diff --git a/content/media/AudioNodeStream.cpp b/content/media/AudioNodeStream.cpp index 61d86c2386d6..c86b4b38a76f 100644 --- a/content/media/AudioNodeStream.cpp +++ b/content/media/AudioNodeStream.cpp @@ -286,6 +286,20 @@ AudioNodeStream::ObtainInputBlock(AudioChunk& aTmpChunk, uint32_t aPortIndex) a->IsAudioParamStream()) { continue; } + + // It is possible for mLastChunks to be empty here, because `a` might be a + // AudioNodeStream that has not been scheduled yet, because it is further + // down the graph _but_ as a connection to this node. Because we enforce the + // presence of at least one DelayNode, with at least one block of delay, and + // because the output of a DelayNode when it has been fed less that + // `delayTime` amount of audio is silence, we can simply continue here, + // because this input would not influence the output of this node. Next + // iteration, a->mLastChunks.IsEmpty() will be false, and everthing will + // work as usual. + if (a->mLastChunks.IsEmpty()) { + continue; + } + AudioChunk* chunk = &a->mLastChunks[mInputs[i]->OutputNumber()]; MOZ_ASSERT(chunk); if (chunk->IsNull() || chunk->mChannelData.IsEmpty()) { @@ -412,8 +426,7 @@ AudioNodeStream::ProduceOutput(GraphTime aFrom, GraphTime aTo) uint16_t outputCount = std::max(uint16_t(1), mEngine->OutputCount()); mLastChunks.SetLength(outputCount); - if (mInCycle) { - // XXX DelayNode not supported yet so just produce silence + if (mMuted) { for (uint16_t i = 0; i < outputCount; ++i) { mLastChunks[i].SetNull(WEBAUDIO_BLOCK_SIZE); } diff --git a/content/media/AudioNodeStream.h b/content/media/AudioNodeStream.h index f042b4732bbb..376f587a5bfc 100644 --- a/content/media/AudioNodeStream.h +++ b/content/media/AudioNodeStream.h @@ -21,6 +21,7 @@ namespace mozilla { namespace dom { struct ThreeDPoint; class AudioParamTimeline; +class DelayNodeEngine; } class ThreadSharedFloatArrayBufferList; @@ -54,7 +55,8 @@ public: mKind(aKind), mNumberOfInputChannels(2), mMarkAsFinishedAfterThisBlock(false), - mAudioParamStream(false) + mAudioParamStream(false), + mMuted(false) { MOZ_ASSERT(NS_IsMainThread()); mChannelCountMode = dom::ChannelCountMode::Max; @@ -103,6 +105,14 @@ public: { return mAudioParamStream; } + void Mute() { + mMuted = true; + } + + void Unmute() { + mMuted = false; + } + const OutputChunks& LastChunks() const { return mLastChunks; @@ -153,6 +163,8 @@ protected: bool mMarkAsFinishedAfterThisBlock; // Whether the stream is an AudioParamHelper stream. bool mAudioParamStream; + // Whether the stream is muted. Access only on the MediaStreamGraph thread. + bool mMuted; }; } diff --git a/content/media/MediaStreamGraph.cpp b/content/media/MediaStreamGraph.cpp index aec533b7cb1e..bc9f724ad11f 100644 --- a/content/media/MediaStreamGraph.cpp +++ b/content/media/MediaStreamGraph.cpp @@ -472,12 +472,32 @@ MediaStreamGraphImpl::UpdateStreamOrderForStream(mozilla::LinkedListmHasBeenOrdered, "stream should not have already been ordered"); if (stream->mIsOnOrderingStack) { MediaStream* iter = aStack->getLast(); + AudioNodeStream* ns = stream->AsAudioNodeStream(); + bool delayNodePresent = ns ? ns->Engine()->AsDelayNodeEngine() != nullptr : false; + bool cycleFound = false; if (iter) { do { + cycleFound = true; iter->AsProcessedStream()->mInCycle = true; + AudioNodeStream* ns = iter->AsAudioNodeStream(); + if (ns && ns->Engine()->AsDelayNodeEngine()) { + delayNodePresent = true; + } iter = iter->getPrevious(); } while (iter && iter != stream); } + if (cycleFound && !delayNodePresent) { + // If we have detected a cycle, the previous loop should exit with stream + // == iter. Go back in the cycle and mute all nodes we find. + MOZ_ASSERT(iter); + do { + // There can't be non-AudioNodeStream here, MediaStreamAudio{Source, + // Destination}Node are connected to regular MediaStreams, but they can't be + // in a cycle (there is no content API to do so). + MOZ_ASSERT(iter->AsAudioNodeStream()); + iter->AsAudioNodeStream()->Mute(); + } while((iter = iter->getNext())); + } return; } ProcessedMediaStream* ps = stream->AsProcessedStream(); @@ -513,6 +533,10 @@ MediaStreamGraphImpl::UpdateStreamOrder() ProcessedMediaStream* ps = stream->AsProcessedStream(); if (ps) { ps->mInCycle = false; + AudioNodeStream* ns = ps->AsAudioNodeStream(); + if (ns) { + ns->Unmute(); + } } } diff --git a/content/media/webaudio/AudioNode.h b/content/media/webaudio/AudioNode.h index a42f63a1a048..93e6ce2884cd 100644 --- a/content/media/webaudio/AudioNode.h +++ b/content/media/webaudio/AudioNode.h @@ -130,6 +130,10 @@ public: return nullptr; } + virtual const DelayNode* AsDelayNode() const { + return nullptr; + } + AudioContext* GetParentObject() const { return mContext; diff --git a/content/media/webaudio/DelayNode.cpp b/content/media/webaudio/DelayNode.cpp index 414c8c64766b..ddf93101deb3 100644 --- a/content/media/webaudio/DelayNode.cpp +++ b/content/media/webaudio/DelayNode.cpp @@ -44,6 +44,11 @@ public: { } + virtual DelayNodeEngine* AsDelayNodeEngine() + { + return this; + } + void SetSourceStream(AudioNodeStream* aSource) { mSource = aSource; diff --git a/content/media/webaudio/DelayNode.h b/content/media/webaudio/DelayNode.h index a46fb64b26df..76438edb110e 100644 --- a/content/media/webaudio/DelayNode.h +++ b/content/media/webaudio/DelayNode.h @@ -32,6 +32,11 @@ public: return mDelay; } + virtual const DelayNode* AsDelayNode() const MOZ_OVERRIDE + { + return this; + } + virtual void NotifyInputConnected() MOZ_OVERRIDE { mMediaStreamGraphUpdateIndexAtLastInputConnection = From 7763e90cd987fbcc9a11e3baee1ba180c82fb6f1 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 13 Sep 2013 18:12:07 +0200 Subject: [PATCH 03/43] Bug 881959 - Tell the MediaStreamGraph when changes to the graph occur. r=roc --HG-- extra : rebase_source : f5c0021e35fa0b66cc45434b5d23742ff3cc3019 --- content/media/MediaStreamGraph.cpp | 8 ++++++++ content/media/MediaStreamGraph.h | 5 +---- content/media/MediaStreamGraphImpl.h | 12 ++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/content/media/MediaStreamGraph.cpp b/content/media/MediaStreamGraph.cpp index bc9f724ad11f..7ef52898b7c3 100644 --- a/content/media/MediaStreamGraph.cpp +++ b/content/media/MediaStreamGraph.cpp @@ -2317,6 +2317,7 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime) , mPostedRunInStableState(false) , mRealtime(aRealtime) , mNonRealtimeProcessing(false) + , mStreamOrderDirty(false) { #ifdef PR_LOGGING if (!gMediaStreamGraphLog) { @@ -2470,4 +2471,11 @@ MediaStreamGraph::StartNonRealtimeProcessing(uint32_t aTicksToProcess) graph->EnsureRunInStableState(); } +void +ProcessedMediaStream::AddInput(MediaInputPort* aPort) +{ + mInputs.AppendElement(aPort); + GraphImpl()->SetStreamOrderDirty(); +} + } diff --git a/content/media/MediaStreamGraph.h b/content/media/MediaStreamGraph.h index 4a05e493a8cc..a2efa053485c 100644 --- a/content/media/MediaStreamGraph.h +++ b/content/media/MediaStreamGraph.h @@ -917,10 +917,7 @@ public: friend class MediaStreamGraphImpl; // Do not call these from outside MediaStreamGraph.cpp! - virtual void AddInput(MediaInputPort* aPort) - { - mInputs.AppendElement(aPort); - } + virtual void AddInput(MediaInputPort* aPort); virtual void RemoveInput(MediaInputPort* aPort) { mInputs.RemoveElement(aPort); diff --git a/content/media/MediaStreamGraphImpl.h b/content/media/MediaStreamGraphImpl.h index 695fb5f1239e..0f3c03a4f784 100644 --- a/content/media/MediaStreamGraphImpl.h +++ b/content/media/MediaStreamGraphImpl.h @@ -365,6 +365,13 @@ public: * Remove aPort from the graph and release it. */ void DestroyPort(MediaInputPort* aPort); + /** + * Mark the media stream order as dirty. + */ + void SetStreamOrderDirty() + { + mStreamOrderDirty = true; + } // Data members @@ -554,6 +561,11 @@ public: * value is only accessed on the main thread. */ bool mNonRealtimeProcessing; + /** + * True when a change has happened which requires us to recompute the stream + * blocking order. + */ + bool mStreamOrderDirty; }; } From 395218d076867a83cb0643b3613cd5afe869522f Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Mon, 2 Sep 2013 15:14:51 +0200 Subject: [PATCH 04/43] Bug 881959 - Tests for cycles in WebAudio graphs. r=ehsan --HG-- extra : rebase_source : 5366c6aa0bb59f14adee74a3088488f9b15b52b1 --- content/media/webaudio/test/Makefile.in | 1 + .../webaudio/test/test_delayNodeCycles.html | 170 ++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 content/media/webaudio/test/test_delayNodeCycles.html diff --git a/content/media/webaudio/test/Makefile.in b/content/media/webaudio/test/Makefile.in index b7a4a8a2e00e..d664763ed7ee 100644 --- a/content/media/webaudio/test/Makefile.in +++ b/content/media/webaudio/test/Makefile.in @@ -57,6 +57,7 @@ MOCHITEST_FILES := \ test_delayNodeAtMax.html \ test_delayNodeSmallMaxDelay.html \ test_delayNodeWithGain.html \ + test_delayNodeCycles.html \ test_dynamicsCompressorNode.html \ test_gainNode.html \ test_gainNodeInLoop.html \ diff --git a/content/media/webaudio/test/test_delayNodeCycles.html b/content/media/webaudio/test/test_delayNodeCycles.html new file mode 100644 index 000000000000..28c2aad49d13 --- /dev/null +++ b/content/media/webaudio/test/test_delayNodeCycles.html @@ -0,0 +1,170 @@ + + + + Test the support of cycles. + + + + +
+
+
+
+ + From a37178b018d4b912c15729384bd551ad6a53fac3 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Mon, 2 Sep 2013 15:15:24 +0200 Subject: [PATCH 05/43] Bug 881959 - Clamp the DelayNode.delayTime to 128/AudioContext.sampleRate when in a cycle. r=ehsan --HG-- extra : rebase_source : 7cf8945371bb6ff169ad61a8ccdda0ece36b5e83 --- content/media/MediaStreamGraph.h | 3 +++ content/media/webaudio/DelayNode.cpp | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/content/media/MediaStreamGraph.h b/content/media/MediaStreamGraph.h index a2efa053485c..82598370336b 100644 --- a/content/media/MediaStreamGraph.h +++ b/content/media/MediaStreamGraph.h @@ -943,6 +943,9 @@ public: */ virtual void ForwardTrackEnabled(TrackID aOutputID, bool aEnabled) {}; + bool InCycle() const { return mInCycle; } + + protected: // This state is all accessed only on the media graph thread. diff --git a/content/media/webaudio/DelayNode.cpp b/content/media/webaudio/DelayNode.cpp index ddf93101deb3..6fed03c9f37f 100644 --- a/content/media/webaudio/DelayNode.cpp +++ b/content/media/webaudio/DelayNode.cpp @@ -128,18 +128,28 @@ public: float* const* outputChannels = reinterpret_cast (const_cast(aOutput->mChannelData.Elements())); + + bool inCycle = aStream->AsProcessedStream()->InCycle(); double sampleRate = aStream->SampleRate(); if (mDelay.HasSimpleValue()) { - double delayFrames = mDelay.GetValue() * sampleRate; - mProcessor.Process(delayFrames, inputChannels, outputChannels, + // If this DelayNode is in a cycle, make sure the delay value is at least + // one block. + float delayFrames = mDelay.GetValue() * sampleRate; + float delayFramesClamped = inCycle ? std::max(static_cast(WEBAUDIO_BLOCK_SIZE), delayFrames) : + delayFrames; + mProcessor.Process(delayFramesClamped, inputChannels, outputChannels, numChannels, WEBAUDIO_BLOCK_SIZE); } else { // Compute the delay values for the duration of the input AudioChunk + // If this DelayNode is in a cycle, make sure the delay value is at least + // one block. double computedDelay[WEBAUDIO_BLOCK_SIZE]; TrackTicks tick = aStream->GetCurrentPosition(); for (size_t counter = 0; counter < WEBAUDIO_BLOCK_SIZE; ++counter) { - computedDelay[counter] = - mDelay.GetValueAtTime(tick, counter) * sampleRate; + float delayAtTick = mDelay.GetValueAtTime(tick, counter) * sampleRate; + float delayAtTickClamped = inCycle ? std::max(static_cast(WEBAUDIO_BLOCK_SIZE), delayAtTick) : + delayAtTick; + computedDelay[counter] = delayAtTickClamped; } mProcessor.Process(computedDelay, inputChannels, outputChannels, numChannels, WEBAUDIO_BLOCK_SIZE); From ae09c349ad439d56f4040c63a32321941dc5ad65 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Mon, 16 Sep 2013 17:37:27 +0200 Subject: [PATCH 06/43] Bug 881959 - Handle self-connection. r=ehsan --HG-- extra : rebase_source : f2d4a0a28cb85668f80c58d1a56926f65ea40e72 --- content/media/MediaStreamGraph.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/content/media/MediaStreamGraph.cpp b/content/media/MediaStreamGraph.cpp index 7ef52898b7c3..5eee2fc6bdc1 100644 --- a/content/media/MediaStreamGraph.cpp +++ b/content/media/MediaStreamGraph.cpp @@ -488,15 +488,22 @@ MediaStreamGraphImpl::UpdateStreamOrderForStream(mozilla::LinkedListAsAudioNodeStream()); + // == iter, or the node is connected to itself. Go back in the cycle and + // mute all nodes we find, or just mute the node itself. + if (!iter) { + // The node is connected to itself. + iter = aStack->getLast(); iter->AsAudioNodeStream()->Mute(); - } while((iter = iter->getNext())); + } else { + MOZ_ASSERT(iter); + do { + // There can't be non-AudioNodeStream here, MediaStreamAudio{Source, + // Destination}Node are connected to regular MediaStreams, but they can't be + // in a cycle (there is no content API to do so). + MOZ_ASSERT(iter->AsAudioNodeStream()); + iter->AsAudioNodeStream()->Mute(); + } while((iter = iter->getNext())); + } } return; } From a4808ff3f86b8dbca53a0eba8ee8ba8ee8649343 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 13:20:17 +0100 Subject: [PATCH 07/43] Bug 917817 - Make several more python test harness failure modes TBPL parsable; r=jmaher --- layout/tools/reftest/remotereftest.py | 6 +++--- testing/mochitest/runtests.py | 8 ++++---- testing/mochitest/runtestsb2g.py | 2 +- testing/mochitest/runtestsremote.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/layout/tools/reftest/remotereftest.py b/layout/tools/reftest/remotereftest.py index 36d1a5006678..5571fc4a76a1 100644 --- a/layout/tools/reftest/remotereftest.py +++ b/layout/tools/reftest/remotereftest.py @@ -213,7 +213,7 @@ class ReftestServer: self._process = self._automation.Process([xpcshell] + args, env = env) pid = self._process.pid if pid < 0: - print "Error starting server." + print "TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server." return 2 self._automation.log.info("INFO | remotereftests.py | Server pid: %d", pid) @@ -233,7 +233,7 @@ class ReftestServer: time.sleep(1) i += 1 else: - print "Timed out while waiting for server startup." + print "TEST-UNEXPECTED-FAIL | remotereftests.py | Timed out while waiting for server startup." self.stop() return 1 @@ -438,7 +438,7 @@ def main(args): else: dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot) except devicemanager.DMError: - print "Error: exception while initializing devicemanager. Most likely the device is not in a testable state." + print "Automation Error: exception while initializing devicemanager. Most likely the device is not in a testable state." return 1 automation.setDeviceManager(dm) diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index cfd25ec56376..7375289a4da5 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -86,7 +86,7 @@ class MochitestServer: self._process = self._automation.Process([xpcshell] + args, env = env) pid = self._process.pid if pid < 0: - log.error("Error starting server.") + log.error("TEST-UNEXPECTED-FAIL | runtests.py | Error starting server.") sys.exit(2) log.info("runtests.py | Server pid: %d", pid) @@ -101,7 +101,7 @@ class MochitestServer: time.sleep(1) i += 1 else: - log.error("Timed out while waiting for server startup.") + log.error("TEST-UNEXPECTED-FAIL | runtests.py | Timed out while waiting for server startup.") self.stop() sys.exit(1) @@ -147,7 +147,7 @@ class WebSocketServer(object): self._process = self._automation.Process(cmd) pid = self._process.pid if pid < 0: - log.error("Error starting websocket server.") + log.error("TEST-UNEXPECTED-FAIL | runtests.py | Error starting websocket server.") sys.exit(2) log.info("runtests.py | Websocket server pid: %d", pid) @@ -608,7 +608,7 @@ class Mochitest(MochitestUtilsMixin): status = -1 except: traceback.print_exc() - log.error("runtests.py | Received unexpected exception while running application\n") + log.error("Automation Error: Received unexpected exception while running application\n") status = 1 if options.vmwareRecording: diff --git a/testing/mochitest/runtestsb2g.py b/testing/mochitest/runtestsb2g.py index b8978745214b..f6cd824eeda7 100644 --- a/testing/mochitest/runtestsb2g.py +++ b/testing/mochitest/runtestsb2g.py @@ -142,7 +142,7 @@ class B2GMochitest(MochitestUtilsMixin): status = -1 except: traceback.print_exc() - log.error("runtests.py | Received unexpected exception while running application\n") + log.error("Automation Error: Received unexpected exception while running application\n") status = 1 self.stopWebServer(options) diff --git a/testing/mochitest/runtestsremote.py b/testing/mochitest/runtestsremote.py index bab93c84b981..86bcaf6d6c96 100644 --- a/testing/mochitest/runtestsremote.py +++ b/testing/mochitest/runtestsremote.py @@ -423,7 +423,7 @@ class MochiRemote(Mochitest): if fail_found: result = 1 if not end_found: - log.error("missing end of test marker (process crashed?)") + log.error("Automation Error: Missing end of test marker (process crashed?)") result = 1 return result From ee8268ad59ce3564c8411a059d1971b698bb96dd Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Thu, 19 Sep 2013 14:45:25 +0200 Subject: [PATCH 08/43] Bug 916094 - Assertions removed from IDBFactory::Create() when it's used in JS from chrome in IPC. r=bent --- dom/indexedDB/IDBFactory.cpp | 32 ++++++++++++--------- dom/quota/QuotaManager.cpp | 54 +++++++++++++++++------------------- dom/quota/QuotaManager.h | 6 ++++ 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index d446c34ee700..4303c9a2a682 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -191,10 +191,8 @@ IDBFactory::Create(JSContext* aCx, nsCString origin; StoragePrivilege privilege; PersistenceType defaultPersistenceType; - nsresult rv = - QuotaManager::GetInfoFromWindow(nullptr, &group, &origin, &privilege, - &defaultPersistenceType); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + QuotaManager::GetInfoForChrome(&group, &origin, &privilege, + &defaultPersistenceType); nsRefPtr factory = new IDBFactory(); factory->mGroup = group; @@ -231,6 +229,15 @@ IDBFactory::Create(ContentParent* aContentParent, NS_ASSERTION(!nsContentUtils::GetCurrentJSContext(), "Should be called from C++"); + // We need to get this information before we push a null principal to avoid + // IsCallerChrome() assertion in quota manager. + nsCString group; + nsCString origin; + StoragePrivilege privilege; + PersistenceType defaultPersistenceType; + QuotaManager::GetInfoForChrome(&group, &origin, &privilege, + &defaultPersistenceType); + nsCOMPtr principal = do_CreateInstance("@mozilla.org/nullprincipal;1"); NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); @@ -253,9 +260,13 @@ IDBFactory::Create(ContentParent* aContentParent, JSAutoCompartment ac(cx, global); - nsRefPtr factory; - rv = Create(cx, global, aContentParent, getter_AddRefs(factory)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr factory = new IDBFactory(); + factory->mGroup = group; + factory->mASCIIOrigin = origin; + factory->mPrivilege = privilege; + factory->mDefaultPersistenceType = defaultPersistenceType; + factory->mOwningObject = global; + factory->mContentParent = aContentParent; mozilla::HoldJSObjects(factory.get()); factory->mRootedOwningObject = true; @@ -609,12 +620,7 @@ IDBFactory::OpenInternal(const nsAString& aName, rv = openHelper->WaitForOpenAllowed(); } else { - StoragePrivilege openerPrivilege; - rv = QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, - &openerPrivilege, nullptr); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - if (openerPrivilege != Chrome && + if (mPrivilege != Chrome && aPersistenceType == PERSISTENCE_TYPE_PERSISTENT) { nsRefPtr permissionHelper = new CheckPermissionsHelper(openHelper, window); diff --git a/dom/quota/QuotaManager.cpp b/dom/quota/QuotaManager.cpp index dbb95bc085e1..aa3e2d802165 100644 --- a/dom/quota/QuotaManager.cpp +++ b/dom/quota/QuotaManager.cpp @@ -925,27 +925,6 @@ GetTemporaryStorageLimit(nsIFile* aDirectory, uint64_t aCurrentUsage, return NS_OK; } -void -GetInfoForChrome(nsACString* aGroup, nsACString* aASCIIOrigin, - StoragePrivilege* aPrivilege, - PersistenceType* aDefaultPersistenceType) -{ - static const char kChromeOrigin[] = "chrome"; - - if (aGroup) { - aGroup->AssignLiteral(kChromeOrigin); - } - if (aASCIIOrigin) { - aASCIIOrigin->AssignLiteral(kChromeOrigin); - } - if (aPrivilege) { - *aPrivilege = Chrome; - } - if (aDefaultPersistenceType) { - *aDefaultPersistenceType = PERSISTENCE_TYPE_PERSISTENT; - } -} - } // anonymous namespace QuotaManager::QuotaManager() @@ -2163,13 +2142,7 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindow* aWindow, { NS_ASSERTION(NS_IsMainThread(), "We're about to touch a window off the main thread!"); - - if (!aWindow) { - NS_ASSERTION(nsContentUtils::IsCallerChrome(), - "Null window but not chrome!"); - GetInfoForChrome(aGroup, aASCIIOrigin, aPrivilege, aDefaultPersistenceType); - return NS_OK; - } + NS_ASSERTION(aWindow, "Don't hand me a null window!"); nsCOMPtr sop = do_QueryInterface(aWindow); NS_ENSURE_TRUE(sop, NS_ERROR_FAILURE); @@ -2184,6 +2157,31 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindow* aWindow, return NS_OK; } +// static +void +QuotaManager::GetInfoForChrome(nsACString* aGroup, + nsACString* aASCIIOrigin, + StoragePrivilege* aPrivilege, + PersistenceType* aDefaultPersistenceType) +{ + NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!"); + + static const char kChromeOrigin[] = "chrome"; + + if (aGroup) { + aGroup->AssignLiteral(kChromeOrigin); + } + if (aASCIIOrigin) { + aASCIIOrigin->AssignLiteral(kChromeOrigin); + } + if (aPrivilege) { + *aPrivilege = Chrome; + } + if (aDefaultPersistenceType) { + *aDefaultPersistenceType = PERSISTENCE_TYPE_PERSISTENT; + } +} + NS_IMPL_ISUPPORTS2(QuotaManager, nsIQuotaManager, nsIObserver) NS_IMETHODIMP diff --git a/dom/quota/QuotaManager.h b/dom/quota/QuotaManager.h index 48ee59515e21..388c24f40118 100644 --- a/dom/quota/QuotaManager.h +++ b/dom/quota/QuotaManager.h @@ -314,6 +314,12 @@ public: StoragePrivilege* aPrivilege, PersistenceType* aDefaultPersistenceType); + static void + GetInfoForChrome(nsACString* aGroup, + nsACString* aASCIIOrigin, + StoragePrivilege* aPrivilege, + PersistenceType* aDefaultPersistenceType); + static void GetOriginPatternString(uint32_t aAppId, bool aBrowserOnly, const nsACString& aOrigin, nsAutoCString& _retval) From c36df6710cd265ee4d26dbf57426b077868766b1 Mon Sep 17 00:00:00 2001 From: Deian Stefan Date: Sun, 23 Jun 2013 14:31:52 -0700 Subject: [PATCH 09/43] Bug 886164 - Enforce CSP in sandboxed iframe. r=grobinson --- caps/include/nsNullPrincipal.h | 2 + caps/src/nsNullPrincipal.cpp | 18 +- content/base/src/contentSecurityPolicy.js | 21 +- content/base/src/nsDocument.cpp | 3 +- content/base/test/csp/Makefile.in | 13 ++ content/base/test/csp/file_bug886164.html | 15 ++ .../test/csp/file_bug886164.html^headers^ | 1 + content/base/test/csp/file_bug886164_2.html | 14 ++ .../test/csp/file_bug886164_2.html^headers^ | 1 + content/base/test/csp/file_bug886164_3.html | 12 ++ .../test/csp/file_bug886164_3.html^headers^ | 1 + content/base/test/csp/file_bug886164_4.html | 12 ++ .../test/csp/file_bug886164_4.html^headers^ | 1 + content/base/test/csp/file_bug886164_5.html | 26 +++ .../test/csp/file_bug886164_5.html^headers^ | 1 + content/base/test/csp/file_bug886164_6.html | 35 ++++ .../test/csp/file_bug886164_6.html^headers^ | 1 + content/base/test/csp/test_bug886164.html | 185 ++++++++++++++++++ 18 files changed, 343 insertions(+), 19 deletions(-) create mode 100644 content/base/test/csp/file_bug886164.html create mode 100644 content/base/test/csp/file_bug886164.html^headers^ create mode 100644 content/base/test/csp/file_bug886164_2.html create mode 100644 content/base/test/csp/file_bug886164_2.html^headers^ create mode 100644 content/base/test/csp/file_bug886164_3.html create mode 100644 content/base/test/csp/file_bug886164_3.html^headers^ create mode 100644 content/base/test/csp/file_bug886164_4.html create mode 100644 content/base/test/csp/file_bug886164_4.html^headers^ create mode 100644 content/base/test/csp/file_bug886164_5.html create mode 100644 content/base/test/csp/file_bug886164_5.html^headers^ create mode 100644 content/base/test/csp/file_bug886164_6.html create mode 100644 content/base/test/csp/file_bug886164_6.html^headers^ create mode 100644 content/base/test/csp/test_bug886164.html diff --git a/caps/include/nsNullPrincipal.h b/caps/include/nsNullPrincipal.h index 10b83f3cfa0c..7e7b1c68bb58 100644 --- a/caps/include/nsNullPrincipal.h +++ b/caps/include/nsNullPrincipal.h @@ -16,6 +16,7 @@ #include "nsJSPrincipals.h" #include "nsCOMPtr.h" #include "nsPrincipal.h" +#include "nsIContentSecurityPolicy.h" class nsIURI; @@ -53,6 +54,7 @@ public: virtual ~nsNullPrincipal(); nsCOMPtr mURI; + nsCOMPtr mCSP; }; #endif // nsNullPrincipal_h__ diff --git a/caps/src/nsNullPrincipal.cpp b/caps/src/nsNullPrincipal.cpp index 9ff9730bc8df..1ceffdd1ef48 100644 --- a/caps/src/nsNullPrincipal.cpp +++ b/caps/src/nsNullPrincipal.cpp @@ -149,8 +149,7 @@ nsNullPrincipal::GetHashValue(uint32_t *aResult) NS_IMETHODIMP nsNullPrincipal::GetSecurityPolicy(void** aSecurityPolicy) { - // We don't actually do security policy caching. And it's not like anyone - // can set a security policy for us anyway. + // We don't actually do security policy caching. *aSecurityPolicy = nullptr; return NS_OK; } @@ -158,8 +157,7 @@ nsNullPrincipal::GetSecurityPolicy(void** aSecurityPolicy) NS_IMETHODIMP nsNullPrincipal::SetSecurityPolicy(void* aSecurityPolicy) { - // We don't actually do security policy caching. And it's not like anyone - // can set a security policy for us anyway. + // We don't actually do security policy caching. return NS_OK; } @@ -172,16 +170,20 @@ nsNullPrincipal::GetURI(nsIURI** aURI) NS_IMETHODIMP nsNullPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp) { - // CSP on a null principal makes no sense - *aCsp = nullptr; + NS_IF_ADDREF(*aCsp = mCSP); return NS_OK; } NS_IMETHODIMP nsNullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp) { - // CSP on a null principal makes no sense - return NS_ERROR_NOT_AVAILABLE; + // If CSP was already set, it should not be destroyed! Instead, it should + // get set anew when a new principal is created. + if (mCSP) + return NS_ERROR_ALREADY_INITIALIZED; + + mCSP = aCsp; + return NS_OK; } NS_IMETHODIMP diff --git a/content/base/src/contentSecurityPolicy.js b/content/base/src/contentSecurityPolicy.js index 63e17a44ea59..b696d0eddf1e 100644 --- a/content/base/src/contentSecurityPolicy.js +++ b/content/base/src/contentSecurityPolicy.js @@ -49,9 +49,9 @@ function ContentSecurityPolicy() { this._request = ""; this._requestOrigin = ""; - this._requestPrincipal = ""; + this._weakRequestPrincipal = null; this._referrer = ""; - this._docRequest = null; + this._weakDocRequest = { get : function() { return null; } }; CSPdebug("CSP object initialized, no policies to enforce yet"); this._cache = { }; @@ -249,7 +249,7 @@ ContentSecurityPolicy.prototype = { return; // Save the docRequest for fetching a policy-uri - this._docRequest = aChannel; + this._weakDocRequest = Cu.getWeakReference(aChannel); // save the document URI (minus ) and referrer for reporting let uri = aChannel.URI.cloneIgnoringRef(); @@ -260,8 +260,9 @@ ContentSecurityPolicy.prototype = { this._requestOrigin = uri; //store a reference to the principal, that can later be used in shouldLoad - this._requestPrincipal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]. - getService(Components.interfaces.nsIScriptSecurityManager).getChannelPrincipal(aChannel); + this._weakRequestPrincipal = Cu.getWeakReference(Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager) + .getChannelPrincipal(aChannel)); if (aChannel.referrer) { let referrer = aChannel.referrer.cloneIgnoringRef(); @@ -310,13 +311,13 @@ ContentSecurityPolicy.prototype = { if (aSpecCompliant) { newpolicy = CSPRep.fromStringSpecCompliant(aPolicy, selfURI, - this._docRequest, + this._weakDocRequest.get(), this, aReportOnly); } else { newpolicy = CSPRep.fromString(aPolicy, selfURI, - this._docRequest, + this._weakDocRequest.get(), this, aReportOnly); } @@ -434,8 +435,8 @@ ContentSecurityPolicy.prototype = { // we need to set an nsIChannelEventSink on the channel object // so we can tell it to not follow redirects when posting the reports chan.notificationCallbacks = new CSPReportRedirectSink(policy); - if (this._docRequest) { - chan.loadGroup = this._docRequest.loadGroup; + if (this._weakDocRequest.get()) { + chan.loadGroup = this._weakDocRequest.get().loadGroup; } chan.QueryInterface(Ci.nsIUploadChannel) @@ -454,7 +455,7 @@ ContentSecurityPolicy.prototype = { .getService(Ci.nsIContentPolicy); if (contentPolicy.shouldLoad(Ci.nsIContentPolicy.TYPE_CSP_REPORT, chan.URI, this._requestOrigin, - null, null, null, this._requestPrincipal) + null, null, null, this._weakRequestPrincipal.get()) != Ci.nsIContentPolicy.ACCEPT) { continue; // skip unauthorized URIs } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index d317f16491e8..bb42e4b20211 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2681,7 +2681,8 @@ nsDocument::InitCSP(nsIChannel* aChannel) if (csp) { // Copy into principal nsIPrincipal* principal = GetPrincipal(); - principal->SetCsp(csp); + rv = principal->SetCsp(csp); + NS_ENSURE_SUCCESS(rv, rv); #ifdef PR_LOGGING PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("Inserted CSP into principal %p", principal)); diff --git a/content/base/test/csp/Makefile.in b/content/base/test/csp/Makefile.in index 688d7c113acc..51b4e70f0810 100644 --- a/content/base/test/csp/Makefile.in +++ b/content/base/test/csp/Makefile.in @@ -97,6 +97,19 @@ MOCHITEST_FILES := \ file_bug836922_npolicies.html^headers^ \ file_bug836922_npolicies_violation.sjs \ file_bug836922_npolicies_ro_violation.sjs \ + test_bug886164.html \ + file_bug886164.html \ + file_bug886164.html^headers^ \ + file_bug886164_2.html \ + file_bug886164_2.html^headers^ \ + file_bug886164_3.html \ + file_bug886164_3.html^headers^ \ + file_bug886164_4.html \ + file_bug886164_4.html^headers^ \ + file_bug886164_5.html \ + file_bug886164_5.html^headers^ \ + file_bug886164_6.html \ + file_bug886164_6.html^headers^ \ $(NULL) MOCHITEST_CHROME_FILES := \ diff --git a/content/base/test/csp/file_bug886164.html b/content/base/test/csp/file_bug886164.html new file mode 100644 index 000000000000..e47c2bc5da5a --- /dev/null +++ b/content/base/test/csp/file_bug886164.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/content/base/test/csp/file_bug886164.html^headers^ b/content/base/test/csp/file_bug886164.html^headers^ new file mode 100644 index 000000000000..4c6fa3c26a77 --- /dev/null +++ b/content/base/test/csp/file_bug886164.html^headers^ @@ -0,0 +1 @@ +Content-Security-Policy: default-src 'self' diff --git a/content/base/test/csp/file_bug886164_2.html b/content/base/test/csp/file_bug886164_2.html new file mode 100644 index 000000000000..f08826f698ff --- /dev/null +++ b/content/base/test/csp/file_bug886164_2.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/content/base/test/csp/file_bug886164_2.html^headers^ b/content/base/test/csp/file_bug886164_2.html^headers^ new file mode 100644 index 000000000000..4c6fa3c26a77 --- /dev/null +++ b/content/base/test/csp/file_bug886164_2.html^headers^ @@ -0,0 +1 @@ +Content-Security-Policy: default-src 'self' diff --git a/content/base/test/csp/file_bug886164_3.html b/content/base/test/csp/file_bug886164_3.html new file mode 100644 index 000000000000..7cefd6569c86 --- /dev/null +++ b/content/base/test/csp/file_bug886164_3.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/content/base/test/csp/file_bug886164_3.html^headers^ b/content/base/test/csp/file_bug886164_3.html^headers^ new file mode 100644 index 000000000000..6581fd425ed9 --- /dev/null +++ b/content/base/test/csp/file_bug886164_3.html^headers^ @@ -0,0 +1 @@ +Content-Security-Policy: default-src 'none' diff --git a/content/base/test/csp/file_bug886164_4.html b/content/base/test/csp/file_bug886164_4.html new file mode 100644 index 000000000000..146c6ba01fcd --- /dev/null +++ b/content/base/test/csp/file_bug886164_4.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/content/base/test/csp/file_bug886164_4.html^headers^ b/content/base/test/csp/file_bug886164_4.html^headers^ new file mode 100644 index 000000000000..6581fd425ed9 --- /dev/null +++ b/content/base/test/csp/file_bug886164_4.html^headers^ @@ -0,0 +1 @@ +Content-Security-Policy: default-src 'none' diff --git a/content/base/test/csp/file_bug886164_5.html b/content/base/test/csp/file_bug886164_5.html new file mode 100644 index 000000000000..1d9bd022c173 --- /dev/null +++ b/content/base/test/csp/file_bug886164_5.html @@ -0,0 +1,26 @@ + + + + + + + I am sandboxed but with only inline "allow-scripts" + + + + + + + + + + + diff --git a/content/base/test/csp/file_bug886164_5.html^headers^ b/content/base/test/csp/file_bug886164_5.html^headers^ new file mode 100644 index 000000000000..3abc19055220 --- /dev/null +++ b/content/base/test/csp/file_bug886164_5.html^headers^ @@ -0,0 +1 @@ +Content-Security-Policy: default-src 'none' 'unsafe-inline'; diff --git a/content/base/test/csp/file_bug886164_6.html b/content/base/test/csp/file_bug886164_6.html new file mode 100644 index 000000000000..211a2aa06694 --- /dev/null +++ b/content/base/test/csp/file_bug886164_6.html @@ -0,0 +1,35 @@ + + + + + + + + + + I am sandboxed but with "allow-scripts" + + + +
+ First name: + Last name: + +
+ + click me + + diff --git a/content/base/test/csp/file_bug886164_6.html^headers^ b/content/base/test/csp/file_bug886164_6.html^headers^ new file mode 100644 index 000000000000..6f9fc3f25de2 --- /dev/null +++ b/content/base/test/csp/file_bug886164_6.html^headers^ @@ -0,0 +1 @@ +Content-Security-Policy: default-src 'self' 'unsafe-inline'; diff --git a/content/base/test/csp/test_bug886164.html b/content/base/test/csp/test_bug886164.html new file mode 100644 index 000000000000..392c01efa009 --- /dev/null +++ b/content/base/test/csp/test_bug886164.html @@ -0,0 +1,185 @@ + + + + + Bug 886164 - Enforce CSP in sandboxed iframe + + + + +

+ + + + + + + + + + + + From a222a7dabd8c5a474bda9ed49cffc2ba8bb6e2b8 Mon Sep 17 00:00:00 2001 From: Yves Gwerder Date: Thu, 19 Sep 2013 09:09:48 -0400 Subject: [PATCH 10/43] Bug 913845 - Fix broken IonSpew filtering with IONFILTER env var. r=hv1989 --- js/src/jit/IonSpewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jit/IonSpewer.cpp b/js/src/jit/IonSpewer.cpp index 30b92427f92c..d6b2e80d3221 100644 --- a/js/src/jit/IonSpewer.cpp +++ b/js/src/jit/IonSpewer.cpp @@ -54,7 +54,7 @@ FilterContainsLocation(HandleScript function) const char *filename = function->filename(); const size_t line = function->lineno; - static size_t filelen = strlen(filename); + const size_t filelen = strlen(filename); const char *index = strstr(filter, filename); while (index) { if (index == filter || index[-1] == ',') { From effab4772e4be28ac5727908d5d46044e7fdd9cb Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Thu, 19 Sep 2013 09:10:04 -0400 Subject: [PATCH 11/43] Bug 914607 - Remove MOZ_WIDGET_GTK2. r=karlt --- configure.in | 1 - dom/plugins/base/nsNPAPIPlugin.cpp | 4 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 2 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 2 +- .../base/nsPluginStreamListenerPeer.cpp | 2 +- dom/plugins/base/nsPluginsDirUnix.cpp | 4 +- dom/plugins/ipc/PluginInstanceChild.cpp | 2 +- gfx/thebes/gfxFT2FontList.cpp | 2 +- image/decoders/icon/nsIconModule.cpp | 2 +- layout/xul/base/src/nsMenuBarFrame.cpp | 2 +- testing/tools/screenshot/gdk-screenshot.cpp | 4 +- .../jsdownloads/src/DownloadPlatform.cpp | 10 +-- toolkit/xre/nsX11ErrorHandler.cpp | 2 +- widget/gtk2/gtkdrawing.h | 4 +- widget/gtk2/mozcontainer.c | 6 +- widget/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/gtk2/nsWindow.cpp | 72 +++++++++---------- widget/gtk2/nsWindow.h | 6 +- 18 files changed, 65 insertions(+), 66 deletions(-) diff --git a/configure.in b/configure.in index 81b764200214..d930e30bf118 100644 --- a/configure.in +++ b/configure.in @@ -4394,7 +4394,6 @@ cairo-gtk2|cairo-gtk2-x11) TK_CFLAGS='$(MOZ_GTK2_CFLAGS)' TK_LIBS='$(MOZ_GTK2_LIBS)' - AC_DEFINE(MOZ_WIDGET_GTK2) MOZ_WIDGET_GTK=2 AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK) MOZ_PDF_PRINTING=1 diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 05dfcd7b7b6a..501f82455215 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -1922,7 +1922,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) return NPERR_NO_ERROR; } } -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) // adobe nppdf calls XtGetApplicationNameAndClass(display, // &instance, &class) we have to init Xt toolkit before get // XtDisplay just call gtk_xtbin_new(w,0) once @@ -1943,7 +1943,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) return NPERR_GENERIC_ERROR; #endif -#if defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_WIDGET_GTK2) \ +#if defined(XP_WIN) || defined(XP_OS2) || (MOZ_WIDGET_GTK == 2) \ || defined(MOZ_WIDGET_QT) case NPNVnetscapeWindow: { if (!npp || !npp->ndata) diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index eb091006b052..97096b55ba44 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -556,7 +556,7 @@ nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window) if (!window || RUNNING != mRunning) return NS_OK; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) // bug 108347, flash plugin on linux doesn't like window->width <= // 0, but Java needs wants this call. if (!nsPluginHost::IsJavaMIMEType(mMIMEType) && window->type == NPWindowTypeWindow && diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 93ed1025d4d2..29b71f7e5e44 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -75,7 +75,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); #include "nsPluginUtilsOSX.h" #endif -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) #include #include #include diff --git a/dom/plugins/base/nsPluginStreamListenerPeer.cpp b/dom/plugins/base/nsPluginStreamListenerPeer.cpp index b1759f47e43c..f06bce65104c 100644 --- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp +++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp @@ -737,7 +737,7 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request, if (owner) { NPWindow* window = nullptr; owner->GetWindow(window); -#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT) +#if (MOZ_WIDGET_GTK == 2) || defined(MOZ_WIDGET_QT) // Should call GetPluginPort() here. // This part is copied from nsPluginInstanceOwner::GetPluginPort(). nsCOMPtr widget; diff --git a/dom/plugins/base/nsPluginsDirUnix.cpp b/dom/plugins/base/nsPluginsDirUnix.cpp index ad1744a97cdd..3724366f515e 100644 --- a/dom/plugins/base/nsPluginsDirUnix.cpp +++ b/dom/plugins/base/nsPluginsDirUnix.cpp @@ -39,7 +39,7 @@ #define DEFAULT_X11_PATH "" #endif -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) #define PLUGIN_MAX_LEN_OF_TMP_ARR 512 @@ -265,7 +265,7 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary) libSpec.value.pathname = path.get(); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) // Normally, Mozilla isn't linked against libXt and libXext // since it's a Gtk/Gdk application. On the other hand, diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index fb83400e55ea..83998fee28d0 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -1101,7 +1101,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) CreateWindow(aWindow); } -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) if (mXEmbed && gtk_check_version(2,18,7) != NULL) { // older if (aWindow.type == NPWindowTypeWindow) { GdkWindow* socket_window = gdk_window_lookup(static_cast(aWindow.window)); diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 258c8bf8fcd7..3453eee9d1a4 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -6,7 +6,7 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) #include "gfxPlatformGtk.h" #define gfxToolkitPlatform gfxPlatformGtk #elif defined(MOZ_WIDGET_QT) diff --git a/image/decoders/icon/nsIconModule.cpp b/image/decoders/icon/nsIconModule.cpp index 4cf7c8f0d1d7..a3de26b6fa21 100644 --- a/image/decoders/icon/nsIconModule.cpp +++ b/image/decoders/icon/nsIconModule.cpp @@ -38,7 +38,7 @@ static const mozilla::Module::CategoryEntry kIconCategories[] = { static void IconDecoderModuleDtor() { -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) nsIconChannel::Shutdown(); #endif } diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp index dfad8ccbb4d1..762d32438282 100644 --- a/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/layout/xul/base/src/nsMenuBarFrame.cpp @@ -149,7 +149,7 @@ nsMenuBarFrame::ToggleMenuActiveState() // Activate the menu bar SetActive(true); -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) firstFrame->OpenMenu(true); #else firstFrame->SelectMenu(true); diff --git a/testing/tools/screenshot/gdk-screenshot.cpp b/testing/tools/screenshot/gdk-screenshot.cpp index a8d713822fa4..0a356aa5daaa 100644 --- a/testing/tools/screenshot/gdk-screenshot.cpp +++ b/testing/tools/screenshot/gdk-screenshot.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) gdk_init(&argc, &argv); // TODO GTK3 -#if defined(HAVE_LIBXSS) && defined(MOZ_WIDGET_GTK2) +#if defined(HAVE_LIBXSS) && (MOZ_WIDGET_GTK == 2) int event_base, error_base; Bool have_xscreensaver = XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base); @@ -129,7 +129,7 @@ int main(int argc, char** argv) GdkWindow* window = gdk_get_default_root_window(); GdkPixbuf* screenshot = NULL; // TODO GTK3 -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) screenshot = gdk_pixbuf_get_from_drawable(NULL, window, NULL, 0, 0, 0, 0, gdk_screen_width(), diff --git a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp index a7a2c7eb89c2..8fad2458d9b4 100644 --- a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp +++ b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp @@ -25,7 +25,7 @@ #include "AndroidBridge.h" #endif -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) #include #endif @@ -43,7 +43,7 @@ DownloadPlatform* DownloadPlatform::GetDownloadPlatform() NS_ADDREF(gDownloadPlatformService); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) g_type_init(); #endif @@ -67,10 +67,10 @@ static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpoint nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, const nsACString& aContentType, bool aIsPrivate) { -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK2) +#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || (MOZ_WIDGET_GTK == 2) nsAutoString path; if (aTarget && NS_SUCCEEDED(aTarget->GetPath(path))) { -#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK2) +#if defined(XP_WIN) || (MOZ_WIDGET_GTK == 2) // On Windows and Gtk, add the download to the system's "recent documents" // list, with a pref to disable. { @@ -78,7 +78,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, if (addToRecentDocs && !aIsPrivate) { #ifdef XP_WIN ::SHAddToRecentDocs(SHARD_PATHW, path.get()); -#elif defined(MOZ_WIDGET_GTK2) +#elif (MOZ_WIDGET_GTK == 2) GtkRecentManager* manager = gtk_recent_manager_get_default(); gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(), diff --git a/toolkit/xre/nsX11ErrorHandler.cpp b/toolkit/xre/nsX11ErrorHandler.cpp index d3a48ca468cf..97245e7b67c3 100644 --- a/toolkit/xre/nsX11ErrorHandler.cpp +++ b/toolkit/xre/nsX11ErrorHandler.cpp @@ -58,7 +58,7 @@ X11Error(Display *display, XErrorEvent *event) { } XCloseDisplay(tmpDisplay); -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK == 2) // GDK2 calls XCloseDevice the devices that it opened on startup, but // the XI protocol no longer ensures that the devices will still exist. // If they have been removed, then a BadDevice error results. Ignore diff --git a/widget/gtk2/gtkdrawing.h b/widget/gtk2/gtkdrawing.h index 5d38574bd7ca..cce2f88e0762 100644 --- a/widget/gtk2/gtkdrawing.h +++ b/widget/gtk2/gtkdrawing.h @@ -209,7 +209,7 @@ gint moz_gtk_enable_style_props(style_prop_t styleGetProp); */ gint moz_gtk_shutdown(); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) /** * Retrieves the colormap to use for drawables passed to moz_gtk_widget_paint. */ @@ -217,7 +217,7 @@ GdkColormap* moz_gtk_widget_get_colormap(); #endif /*** Widget drawing ***/ -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) /** * Paint a widget in the current theme. * widget: a constant giving the widget to paint diff --git a/widget/gtk2/mozcontainer.c b/widget/gtk2/mozcontainer.c index 262ea6749c33..ded61f678b55 100644 --- a/widget/gtk2/mozcontainer.c +++ b/widget/gtk2/mozcontainer.c @@ -236,14 +236,14 @@ moz_container_realize (GtkWidget *widget) attributes.visual = gtk_widget_get_visual (widget); attributes.window_type = GDK_WINDOW_CHILD; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask |= GDK_WA_COLORMAP; #endif window = gdk_window_new (parent, &attributes, attributes_mask); gdk_window_set_user_data (window, widget); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) /* TODO GTK3? */ /* set the back pixmap to None so that you don't end up with the gtk default which is BlackPixel */ @@ -256,7 +256,7 @@ moz_container_realize (GtkWidget *widget) gtk_widget_set_window (widget, window); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) widget->style = gtk_style_attach (widget->style, widget->window); #endif } diff --git a/widget/gtk2/nsNativeThemeGTK.cpp b/widget/gtk2/nsNativeThemeGTK.cpp index a22741a97e16..5c4833063342 100644 --- a/widget/gtk2/nsNativeThemeGTK.cpp +++ b/widget/gtk2/nsNativeThemeGTK.cpp @@ -630,7 +630,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, return true; } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) class ThemeRenderer : public gfxGdkNativeRenderer { public: ThemeRenderer(GtkWidgetState aState, GtkThemeWidgetType aGTKWidgetType, @@ -822,7 +822,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext, gdk_error_trap_push (); } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) // The gdk_clip is just advisory here, meaning "you don't // need to draw outside this rect if you don't feel like it!" GdkRectangle gdk_clip = {0, 0, drawingRect.width, drawingRect.height}; diff --git a/widget/gtk2/nsWindow.cpp b/widget/gtk2/nsWindow.cpp index 1e24d7593473..4f844373d601 100644 --- a/widget/gtk2/nsWindow.cpp +++ b/widget/gtk2/nsWindow.cpp @@ -44,7 +44,7 @@ #endif #endif /* MOZ_X11 */ #include -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) #include #endif @@ -156,7 +156,7 @@ static int is_parent_grab_leave(GdkEventCrossing *aEvent); static void GetBrandName(nsXPIDLString& brandName); /* callbacks from widgets */ -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) static gboolean expose_event_cb (GtkWidget *widget, GdkEventExpose *event); #else @@ -302,7 +302,7 @@ protected: static inline int32_t GetBitmapStride(int32_t width) { -#if defined(MOZ_X11) || defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_X11) || (MOZ_WIDGET_GTK == 2) return (width+7)/8; #else return cairo_format_stride_for_width(CAIRO_FORMAT_A1, width); @@ -651,7 +651,7 @@ nsWindow::Destroy(void) gFocusWindow = nullptr; } -#if defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11) +#if (MOZ_WIDGET_GTK == 2) && defined(MOZ_X11) // make sure that we remove ourself as the plugin focus window if (gPluginFocusWindow == this) { gPluginFocusWindow->LoseNonXEmbedPluginFocus(); @@ -1907,7 +1907,7 @@ gdk_window_flash(GdkWindow * aGdkWindow, GdkGC * gc = 0; GdkColor white; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gdk_window_get_geometry(aGdkWindow,NULL,NULL,&width,&height,NULL); #else gdk_window_get_geometry(aGdkWindow,NULL,NULL,&width,&height); @@ -1955,7 +1955,7 @@ gdk_window_flash(GdkWindow * aGdkWindow, #endif // DEBUG #endif -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gboolean nsWindow::OnExposeEvent(GdkEventExpose *aEvent) #else @@ -2000,7 +2000,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) return FALSE; } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) GdkRectangle *rects; gint nrects; gdk_region_get_rectangles(aEvent->region, &rects, &nrects); @@ -2020,7 +2020,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) #endif // GTK3 TODO? -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) if (nrects > MAX_RECTS_IN_REGION) { // Just use the bounding box rects[0] = aEvent->area; @@ -2034,7 +2034,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) nsIntRegion region; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) GdkRectangle *r = rects; GdkRectangle *r_end = rects + nrects; #else @@ -2087,7 +2087,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) } if (region.IsEmpty()) { -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) g_free(rects); #else cairo_rectangle_list_destroy(rects); @@ -2112,7 +2112,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) return TRUE; } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) nsRefPtr ctx = new gfxContext(GetThebesSurface()); #else nsRefPtr ctx = new gfxContext(GetThebesSurface(cr)); @@ -2207,7 +2207,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) } # ifdef MOZ_HAVE_SHMIMAGE if (nsShmImage::UseShm() && MOZ_LIKELY(!mIsDestroyed)) { -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) mShmImage->Put(mGdkWindow, rects, r_end); #else mShmImage->Put(mGdkWindow, rects); @@ -2216,7 +2216,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) # endif // MOZ_HAVE_SHMIMAGE #endif // MOZ_X11 -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) g_free(rects); #else cairo_rectangle_list_destroy(rects); @@ -2225,7 +2225,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) listener->DidPaintWindow(); // Synchronously flush any new dirty areas -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) GdkRegion* dirtyArea = gdk_window_get_update_area(mGdkWindow); #else cairo_region_t* dirtyArea = gdk_window_get_update_area(mGdkWindow); @@ -2233,7 +2233,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) if (dirtyArea) { gdk_window_invalidate_region(mGdkWindow, dirtyArea, false); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gdk_region_destroy(dirtyArea); #else cairo_region_destroy(dirtyArea); @@ -2466,7 +2466,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent) synthEvent = true; XNextEvent (GDK_WINDOW_XDISPLAY(aEvent->window), &xevent); } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) // if plugins still keeps the focus, get it back if (gPluginFocusWindow && gPluginFocusWindow != this) { nsRefPtr kungFuDeathGrip = gPluginFocusWindow; @@ -2814,7 +2814,7 @@ nsWindow::OnContainerFocusOutEvent(GdkEventFocus *aEvent) } } -#if defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11) +#if (MOZ_WIDGET_GTK == 2) && defined(MOZ_X11) // plugin lose focus if (gPluginFocusWindow) { nsRefPtr kungFuDeathGrip = gPluginFocusWindow; @@ -3279,7 +3279,7 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget) attributes.visual = gtk_widget_get_visual(widget); attributes.window_type = GDK_WINDOW_CHILD; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) attributes_mask |= GDK_WA_COLORMAP; attributes.colormap = gtk_widget_get_colormap(widget); #endif @@ -3288,7 +3288,7 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget) gdk_window_set_user_data(window, widget); // GTK3 TODO? -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) /* set the default pixmap to None so that you don't end up with the gtk default which is BlackPixel. */ gdk_window_set_back_pixmap(window, NULL, FALSE); @@ -3420,7 +3420,7 @@ nsWindow::Create(nsIWidget *aParent, // are on a compositing window manager. GdkScreen *screen = gtk_widget_get_screen(mShell); if (gdk_screen_is_composited(screen)) { -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen); gtk_widget_set_colormap(mShell, colormap); @@ -3599,7 +3599,7 @@ nsWindow::Create(nsIWidget *aParent, hierarchy_changed_cb(GTK_WIDGET(mContainer), NULL); // Expose, focus, key, and drag events are sent even to GTK_NO_WINDOW // widgets. -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) g_signal_connect(mContainer, "expose_event", G_CALLBACK(expose_event_cb), NULL); #else @@ -3656,7 +3656,7 @@ nsWindow::Create(nsIWidget *aParent, } if (eventWidget) { -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) // Don't let GTK mess with the shapes of our GdkWindows GTK_PRIVATE_SET_FLAG(eventWidget, GTK_HAS_SHAPE_MASK); #endif @@ -4097,7 +4097,7 @@ nsWindow::SetWindowClipRegion(const nsTArray& aRects, if (!mGdkWindow) return; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) GdkRegion *region = gdk_region_new(); // aborts on OOM for (uint32_t i = 0; i < newRects->Length(); ++i) { const nsIntRect& r = newRects->ElementAt(i); @@ -4227,7 +4227,7 @@ nsWindow::ApplyTransparencyBitmap() maskPixmap, ShapeSet); XFreePixmap(xDisplay, maskPixmap); #else -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gtk_widget_reset_shapes(mShell); GdkBitmap* maskBitmap = gdk_bitmap_create_from_data(gtk_widget_get_window(mShell), mTransparencyBitmap, @@ -4496,7 +4496,7 @@ nsWindow::SetNonXEmbedPluginFocus() LOGFOCUS(("\t curFocusWindow=%p\n", curFocusWindow)); GdkWindow* toplevel = gdk_window_get_toplevel(mGdkWindow); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) GdkWindow *gdkfocuswin = gdk_window_lookup(curFocusWindow); #else GdkWindow *gdkfocuswin = gdk_x11_window_lookup_for_display(gdkDisplay, @@ -4779,7 +4779,7 @@ is_mouse_in_window (GdkWindow* aWindow, gdouble aMouseX, gdouble aMouseY) window = gdk_window_get_parent(window); } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gdk_drawable_get_size(aWindow, &w, &h); #else w = gdk_window_get_width(aWindow); @@ -4983,7 +4983,7 @@ get_gtk_cursor(nsCursor aCursor) // gtk callbacks -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) static gboolean expose_event_cb(GtkWidget *widget, GdkEventExpose *event) { @@ -5290,7 +5290,7 @@ plugin_window_filter_func(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) break; xeventWindow = xevent->xreparent.window; } -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) plugin_window = gdk_window_lookup(xeventWindow); #else plugin_window = gdk_x11_window_lookup_for_display( @@ -5301,7 +5301,7 @@ plugin_window_filter_func(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) get_gtk_widget_for_gdk_window(plugin_window); // TODO GTK3 -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) if (GTK_IS_XTBIN(widget)) { nswindow->SetPluginType(nsWindow::PluginType_NONXEMBED); break; @@ -5668,7 +5668,7 @@ get_inner_gdk_window (GdkWindow *aWindow, child = g_list_previous(child)) { GdkWindow *childWindow = (GdkWindow *) child->data; if (get_window_for_gdk_window(childWindow)) { -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gdk_window_get_geometry(childWindow, &cx, &cy, &cw, &ch, NULL); #else gdk_window_get_geometry(childWindow, &cx, &cy, &cw, &ch); @@ -5868,7 +5868,7 @@ nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) return NS_OK; } -#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2) /* static */ already_AddRefed nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, const nsIntSize& aSize) @@ -5910,7 +5910,7 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, } #endif -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) TemporaryRef nsWindow::StartRemoteDrawing() { @@ -5930,7 +5930,7 @@ nsWindow::StartRemoteDrawing() // return the gfxASurface for rendering to this widget gfxASurface* -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) nsWindow::GetThebesSurface() #else nsWindow::GetThebesSurface(cairo_t *cr) @@ -5939,7 +5939,7 @@ nsWindow::GetThebesSurface(cairo_t *cr) if (!mGdkWindow) return nullptr; -#if !defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK != 2) cairo_surface_t *surf = cairo_get_target(cr); if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { NS_NOTREACHED("Missing cairo target?"); @@ -5950,7 +5950,7 @@ nsWindow::GetThebesSurface(cairo_t *cr) #ifdef MOZ_X11 gint width, height; -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gdk_drawable_get_size(GDK_DRAWABLE(mGdkWindow), &width, &height); #else width = gdk_window_get_width(mGdkWindow); @@ -5980,7 +5980,7 @@ nsWindow::GetThebesSurface(cairo_t *cr) if (!usingShm) # endif // MOZ_HAVE_SHMIMAGE -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) mThebesSurface = new gfxXlibSurface (GDK_WINDOW_XDISPLAY(mGdkWindow), gdk_x11_window_get_xid(mGdkWindow), diff --git a/widget/gtk2/nsWindow.h b/widget/gtk2/nsWindow.h index 076a8e16d087..0651b9876965 100644 --- a/widget/gtk2/nsWindow.h +++ b/widget/gtk2/nsWindow.h @@ -164,7 +164,7 @@ public: gint ConvertBorderStyles(nsBorderStyle aStyle); // event callbacks -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gboolean OnExposeEvent(GdkEventExpose *aEvent); #else gboolean OnExposeEvent(cairo_t *cr); @@ -196,7 +196,7 @@ public: guint aTime, gpointer aData); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) mozilla::TemporaryRef StartRemoteDrawing() MOZ_OVERRIDE; #endif @@ -277,7 +277,7 @@ public: nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect, uint8_t* aAlphas, int32_t aStride); -#if defined(MOZ_WIDGET_GTK2) +#if (MOZ_WIDGET_GTK == 2) gfxASurface *GetThebesSurface(); static already_AddRefed GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, From 2fdf36e4b2a780b1144ee4f15e46e4d5b1f9cc76 Mon Sep 17 00:00:00 2001 From: Douglas Crosher Date: Thu, 19 Sep 2013 00:31:35 +1000 Subject: [PATCH 12/43] Bug 917800 - Odinmonkey: Correct rounding up of the heap length. r=luke --- js/src/jit-test/tests/asm.js/testHeapAccess.js | 9 +++++++++ js/src/jit/AsmJS.cpp | 2 +- js/src/jit/AsmJSLink.cpp | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/js/src/jit-test/tests/asm.js/testHeapAccess.js b/js/src/jit-test/tests/asm.js/testHeapAccess.js index d484c5956650..03dca78cfb27 100644 --- a/js/src/jit-test/tests/asm.js/testHeapAccess.js +++ b/js/src/jit-test/tests/asm.js/testHeapAccess.js @@ -564,6 +564,9 @@ new Uint8Array(buf)[0xfffff] = 0xAA; assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfffff),0xAA); assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x100000),0); +var buf = new ArrayBuffer(0x104000); +new Uint8Array(buf)[0x103fff] = 0xAA; +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x103fff]|0; } return f'), this, null, buf)(),0xAA); var buf = new ArrayBuffer(0x3f8000); new Uint8Array(buf)[0x3f7fff] = 0xAA; assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); @@ -576,6 +579,9 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fc000),0); var buf = new ArrayBuffer(0x3fe000); assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); +var buf = new ArrayBuffer(0x410000); +new Uint8Array(buf)[0x40ffff] = 0xAA; +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x40ffff]|0; } return f'), this, null, buf)(),0xAA); // The rest are getting too large for regular testing. //var buf = new ArrayBuffer(0xfe8000); //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); @@ -604,6 +610,9 @@ assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'funct //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xff00000),0); //var buf = new ArrayBuffer(0xff80000); //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); +//var buf = new ArrayBuffer(0x10400000); +//new Uint8Array(buf)[0x103fffff] = 0xAA; +//assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x103fffff]|0; } return f'), this, null, buf)(),0xAA); //var buf = new ArrayBuffer(0x3fa00000); //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); //var buf = new ArrayBuffer(0x3fc00000); // 1020M diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index 2f84e602f376..c53ab4b636f3 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -960,7 +960,7 @@ js::RoundUpToNextValidAsmJSHeapLength(uint32_t length) return (length + 0x0003ffff) & ~0x0003ffff; if (length < 0x10000000u) // < 256M quanta 1M return (length + 0x000fffff) & ~0x000fffff; - if (length < 0x10000000u) // < 1024M quanta 4M + if (length < 0x40000000u) // < 1024M quanta 4M return (length + 0x003fffff) & ~0x003fffff; // < 4096M quanta 16M. Note zero is returned if over 0xff000000 but such // lengths are not currently valid. diff --git a/js/src/jit/AsmJSLink.cpp b/js/src/jit/AsmJSLink.cpp index 1a1e37b5420d..7e30480a5d7e 100644 --- a/js/src/jit/AsmJSLink.cpp +++ b/js/src/jit/AsmJSLink.cpp @@ -224,8 +224,10 @@ DynamicallyLinkModule(JSContext *cx, CallArgs args, AsmJSModule &module) // This check is sufficient without considering the size of the loaded datum because heap // loads and stores start on an aligned boundary and the heap byteLength has larger alignment. JS_ASSERT((module.minHeapLength() - 1) <= INT32_MAX); - if (heap->byteLength() < module.minHeapLength()) - return LinkFail(cx, "ArrayBuffer byteLength less than the largest source code heap length constraint."); + if (heap->byteLength() < module.minHeapLength()) { + return LinkFail(cx, JS_smprintf("ArrayBuffer byteLength of 0x%x is less than 0x%x (which is the largest constant heap access offset rounded up to the next valid heap size).", + heap->byteLength(), module.minHeapLength())); + } if (!ArrayBufferObject::prepareForAsmJS(cx, heap)) return LinkFail(cx, "Unable to prepare ArrayBuffer for asm.js use"); From 814bf21467042cf6e16e09714e9a47446831a4f0 Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Thu, 19 Sep 2013 09:12:48 -0400 Subject: [PATCH 13/43] Bug 907351 - Android pandaboard reftests run significantly slower; r=gbrown --- layout/reftests/bugs/reftest.list | 2 +- layout/tools/reftest/remotereftest.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index ddf89d5c9152..415f04bda19c 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1490,7 +1490,7 @@ skip-if(B2G) fuzzy-if(Android&&AndroidVersion>=15,12,300) == 551463-1.html 55146 # 553571 depends on MS Indic shaping behavior and Win7 font support; # not expected to be reliable on XP or non-Windows platforms random-if(!winWidget) random-if(/^Windows\x20NT\x205/.test(http.oscpu)) != 553571-1.html 553571-1-notref.html # expect dotted circle in test, not in ref -fuzzy-if(!contentSameGfxBackendAsCanvas,2,91) random-if(d2d) skip-if(azureSkiaGL) == 555388-1.html 555388-1-ref.html +fuzzy-if(!contentSameGfxBackendAsCanvas,128,91) random-if(d2d) skip-if(azureSkiaGL) == 555388-1.html 555388-1-ref.html == 556661-1.html 556661-1-ref.html skip-if(B2G) fails-if(Android) == 557087-1.html 557087-ref.html skip-if(B2G) fails-if(Android) == 557087-2.html 557087-ref.html diff --git a/layout/tools/reftest/remotereftest.py b/layout/tools/reftest/remotereftest.py index 5571fc4a76a1..e4feb34a82de 100644 --- a/layout/tools/reftest/remotereftest.py +++ b/layout/tools/reftest/remotereftest.py @@ -369,6 +369,9 @@ class RemoteReftest(RefTest): # Make sure that opening the plugins check page won't hit the network prefs["plugins.update.url"] = "http://127.0.0.1:8888/plugins-dummy/updateCheckURL" + # Disable skia-gl: see bug 907351 + prefs["gfx.canvas.azure.accelerated"] = False + # Set the extra prefs. profile.set_preferences(prefs) From 31eb1565d0ab981ec490ee7429e1b3191c4872b0 Mon Sep 17 00:00:00 2001 From: John Hopkins Date: Thu, 19 Sep 2013 09:40:51 -0400 Subject: [PATCH 14/43] Bug 894903 - Add new VS2010 install location to build PATH. r=ted --- build/win32/mozconfig.vs2010-win64 | 17 ++++++++++++----- build/win64/mozconfig.vs2010 | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/build/win32/mozconfig.vs2010-win64 b/build/win32/mozconfig.vs2010-win64 index 8fbe98f8ff3c..b1461f09b3f7 100644 --- a/build/win32/mozconfig.vs2010-win64 +++ b/build/win32/mozconfig.vs2010-win64 @@ -1,18 +1,25 @@ + +if [ -d "/c/Program Files (x86)/Microsoft Visual Studio 10.0" ]; then + _VSPATH="/c/Program Files (x86)/Microsoft Visual Studio 10.0" +else + _VSPATH="/c/tools/msvs10" +fi + ## SDK redist ## -export WIN32_REDIST_DIR=/c/tools/msvs10/VC/redist/x86/Microsoft.VC100.CRT +export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x86/Microsoft.VC100.CRT ## moz tools location for 64-bit builders ## export MOZ_TOOLS=C:/mozilla-build/moztools ## includes: win8 sdk includes, winrt headers for metro, msvc 10 std library, directx sdk for d3d9 ## -export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl/wrappers:/c/tools/msvs10/vc/include:/c/tools/msvs10/vc/atlmfc/include:/c/tools/sdks/dx10/include +export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl/wrappers:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include ## libs: win8 sdk x86 (32-bit) libs, msvc 10 (32-bit) std library, msvc 10 atl libs, directx sdk (32-bit) for d3d9 ## -export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x86:/c/tools/msvs10/vc/lib:/c/tools/msvs10/vc/atlmfc/lib:/c/tools/sdks/dx10/lib -export LIB=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x86:/c/tools/msvs10/vc/lib:/c/tools/msvs10/vc/atlmfc/lib:/c/tools/sdks/dx10/lib +export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x86:${_VSPATH}/vc/lib:${_VSPATH}/vc/atlmfc/lib:/c/tools/sdks/dx10/lib +export LIB=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x86:${_VSPATH}/vc/lib:${_VSPATH}/vc/atlmfc/lib:/c/tools/sdks/dx10/lib ## paths: win8 sdk x86 (32-bit) tools, msvc 10 (32-bit) build toolchain, moz tools ## -export PATH="/c/Program Files (x86)/Windows Kits/8.0/bin/x86:/c/tools/msvs10/Common7/IDE:/c/tools/msvs10/VC/BIN:/c/tools/msvs10/Common7/Tools:/c/tools/msvs10/VC/VCPackages:/c/mozilla-build/moztools:${PATH}" +export PATH="/c/Program Files (x86)/Windows Kits/8.0/bin/x86:${_VSPATH}/Common7/IDE:${_VSPATH}/VC/BIN:${_VSPATH}/Common7/Tools:${_VSPATH}/VC/VCPackages:/c/mozilla-build/moztools:${PATH}" . $topsrcdir/build/mozconfig.vs2010-common diff --git a/build/win64/mozconfig.vs2010 b/build/win64/mozconfig.vs2010 index d82bada4c438..28b15c362ade 100644 --- a/build/win64/mozconfig.vs2010 +++ b/build/win64/mozconfig.vs2010 @@ -1,15 +1,22 @@ + +if [ -d "/c/Program Files (x86)/Microsoft Visual Studio 10.0" ]; then + _VSPATH="/c/Program Files (x86)/Microsoft Visual Studio 10.0" +else + _VSPATH="/c/tools/msvs10" +fi + ## SDK redist ## -export WIN32_REDIST_DIR=/c/tools/msvs10/VC/redist/x64/Microsoft.VC100.CRT +export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x64/Microsoft.VC100.CRT ## includes: win8 sdk includes, winrt headers for metro, msvc 10 std library, directx sdk for d3d9 ## -export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl/wrappers:/c/tools/msvs10/vc/include:/c/tools/msvs10/vc/atlmfc/include:/c/tools/sdks/dx10/include +export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl/wrappers:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include ## libs: win8 sdk x64 (64-bit) libs, msvc 10 (64-bit) std library, msvc 10 atl libs, directx sdk (64-bit) for d3d9 ## -export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x64:/c/tools/msvs10/vc/lib/amd64:/c/tools/msvs10/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64 -export LIB=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x64:/c/tools/msvs10/vc/lib/amd64:/c/tools/msvs10/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64 +export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x64:${_VSPATH}/vc/lib/amd64:${_VSPATH}/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64 +export LIB=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x64:${_VSPATH}/vc/lib/amd64:${_VSPATH}/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64 ## paths: win8 sdk x64 (64-bit) tools, msvc 10 (64-bit) build toolchain, moz tools ## -export PATH="/c/Program Files (x86)/Windows Kits/8.0/bin/x64:/c/tools/msvs10/Common7/IDE:/c/tools/msvs10/VC/BIN/amd64:/c/tools/msvs10/VC/BIN/x86_amd64:/c/tools/msvs10/VC/BIN:/c/tools/msvs10/Common7/Tools:/c/tools/msvs10/VC/VCPackages:${PATH}" +export PATH="/c/Program Files (x86)/Windows Kits/8.0/bin/x64:${_VSPATH}/Common7/IDE:${_VSPATH}/VC/BIN/amd64:${_VSPATH}/VC/BIN/x86_amd64:${_VSPATH}/VC/BIN:${_VSPATH}/Common7/Tools:${_VSPATH}/VC/VCPackages:${PATH}" # Use 32bit linker for PGO crash bug. # https://connect.microsoft.com/VisualStudio/feedback/details/686117/ From ef57b5655b955fb2e71cae00f06b4d823f2dc821 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 19 Sep 2013 09:54:39 -0400 Subject: [PATCH 15/43] Bug 913847 - stop needlessly including nsThreadUtils.h - r=ehsan --- content/base/src/nsDOMFile.cpp | 1 + content/base/src/nsDocument.h | 1 - content/base/src/nsInProcessTabChildGlobal.h | 2 +- .../html/content/public/HTMLMediaElement.h | 2 +- content/media/dash/DASHDecoder.h | 1 - dom/camera/CameraCommon.h | 1 - dom/file/FileHelper.cpp | 15 +++++++++++++++ dom/file/FileHelper.h | 13 ++----------- dom/indexedDB/FileInfo.cpp | 2 +- dom/indexedDB/FileInfo.h | 2 -- dom/plugins/ipc/PluginHangUIParent.cpp | 1 + dom/plugins/ipc/PluginMessageUtils.h | 1 - dom/quota/QuotaManager.h | 2 +- dom/src/notification/DesktopNotification.h | 1 - gfx/layers/ImageContainer.h | 2 -- gfx/thebes/gfxFontUtils.h | 2 -- media/mtransport/transportflow.h | 1 + media/mtransport/transportlayer.cpp | 16 ++++++++++++++++ media/mtransport/transportlayer.h | 16 +--------------- .../components/build/nsAndroidHistory.cpp | 1 + .../components/build/nsAndroidHistory.h | 2 +- netwerk/base/src/Dashboard.cpp | 1 + netwerk/base/src/EventTokenBucket.cpp | 1 + netwerk/base/src/Tickler.cpp | 1 + netwerk/base/src/Tickler.h | 1 - netwerk/base/src/nsSocketTransport2.cpp | 2 +- .../base/src/nsSocketTransportService2.cpp | 1 + netwerk/base/src/nsSocketTransportService2.h | 2 +- netwerk/base/src/nsUDPServerSocket.h | 1 + netwerk/ipc/ChannelEventQueue.cpp | 16 ++++++++++++++++ netwerk/ipc/ChannelEventQueue.h | 19 +------------------ netwerk/protocol/http/nsHttpChannel.h | 1 - parser/html/nsHtml5Parser.h | 1 - .../src/mozStorageAsyncStatementExecution.h | 2 +- toolkit/components/places/nsNavHistory.h | 1 - widget/android/AndroidBridge.h | 4 +--- widget/windows/JumpListBuilder.h | 1 - widget/windows/WinUtils.cpp | 1 + widget/windows/WinUtils.h | 3 ++- widget/windows/nsSound.cpp | 1 + widget/windows/nsSound.h | 4 +++- 41 files changed, 76 insertions(+), 73 deletions(-) diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp index c65a635ce26e..c312175661ea 100644 --- a/content/base/src/nsDOMFile.cpp +++ b/content/base/src/nsDOMFile.cpp @@ -35,6 +35,7 @@ #include "mozilla/CheckedInt.h" #include "mozilla/Preferences.h" #include "mozilla/Attributes.h" +#include "nsThreadUtils.h" #include "mozilla/dom/FileListBinding.h" using namespace mozilla; diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index ea30f01336e9..a5839cb0ede9 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -53,7 +53,6 @@ #include "pldhash.h" #include "nsAttrAndChildArray.h" #include "nsDOMAttributeMap.h" -#include "nsThreadUtils.h" #include "nsIContentViewer.h" #include "nsIDOMXPathNSResolver.h" #include "nsIInterfaceRequestor.h" diff --git a/content/base/src/nsInProcessTabChildGlobal.h b/content/base/src/nsInProcessTabChildGlobal.h index 903675b6a36f..494e96548fb3 100644 --- a/content/base/src/nsInProcessTabChildGlobal.h +++ b/content/base/src/nsInProcessTabChildGlobal.h @@ -18,7 +18,7 @@ #include "nsIDocShell.h" #include "nsIDOMElement.h" #include "nsCOMArray.h" -#include "nsThreadUtils.h" +#include "nsIRunnable.h" #include "nsIGlobalObject.h" #include "nsIScriptObjectPrincipal.h" #include "nsWeakReference.h" diff --git a/content/html/content/public/HTMLMediaElement.h b/content/html/content/public/HTMLMediaElement.h index d100d8773cfc..f587fd7dc8b5 100644 --- a/content/html/content/public/HTMLMediaElement.h +++ b/content/html/content/public/HTMLMediaElement.h @@ -11,7 +11,6 @@ #include "MediaDecoderOwner.h" #include "nsIChannel.h" #include "nsIHttpChannel.h" -#include "nsThreadUtils.h" #include "nsIDOMRange.h" #include "nsCycleCollectionParticipant.h" #include "nsILoadGroup.h" @@ -45,6 +44,7 @@ class MediaDecoder; class nsITimer; class nsRange; +class nsIRunnable; namespace mozilla { namespace dom { diff --git a/content/media/dash/DASHDecoder.h b/content/media/dash/DASHDecoder.h index 260e31e1bdd4..adc9dfd453e5 100644 --- a/content/media/dash/DASHDecoder.h +++ b/content/media/dash/DASHDecoder.h @@ -18,7 +18,6 @@ #include "nsTArray.h" #include "nsIURI.h" #include "nsITimer.h" -#include "nsThreadUtils.h" #include "MediaDecoder.h" #include "DASHReader.h" diff --git a/dom/camera/CameraCommon.h b/dom/camera/CameraCommon.h index 61d28e4effcd..1f2d418da891 100644 --- a/dom/camera/CameraCommon.h +++ b/dom/camera/CameraCommon.h @@ -19,7 +19,6 @@ #define NAN std::numeric_limits::quiet_NaN() #endif -#include "nsThreadUtils.h" #include "nsIDOMCameraManager.h" #include "prlog.h" diff --git a/dom/file/FileHelper.cpp b/dom/file/FileHelper.cpp index 2c85ab013a78..ed95dc14acf8 100644 --- a/dom/file/FileHelper.cpp +++ b/dom/file/FileHelper.cpp @@ -15,6 +15,7 @@ #include "FileRequest.h" #include "FileService.h" #include "nsIRequest.h" +#include "nsThreadUtils.h" USING_FILE_NAMESPACE @@ -209,3 +210,17 @@ FileHelper::Finish() mRequest), "Subclass didn't call FileHelper::ReleaseObjects!"); } + +void +FileHelper::OnStreamClose() +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + Finish(); +} + +void +FileHelper::OnStreamDestroy() +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + Finish(); +} diff --git a/dom/file/FileHelper.h b/dom/file/FileHelper.h index b82865f67424..90c05e209b8a 100644 --- a/dom/file/FileHelper.h +++ b/dom/file/FileHelper.h @@ -10,7 +10,6 @@ #include "FileCommon.h" #include "nsIRequestObserver.h" -#include "nsThreadUtils.h" class nsIFileStorage; @@ -58,18 +57,10 @@ public: OnStreamProgress(uint64_t aProgress, uint64_t aProgressMax); void - OnStreamClose() - { - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - Finish(); - } + OnStreamClose(); void - OnStreamDestroy() - { - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - Finish(); - } + OnStreamDestroy(); static LockedFile* GetCurrentLockedFile(); diff --git a/dom/indexedDB/FileInfo.cpp b/dom/indexedDB/FileInfo.cpp index f8f085eecb45..5b1c748a95cf 100644 --- a/dom/indexedDB/FileInfo.cpp +++ b/dom/indexedDB/FileInfo.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "FileInfo.h" - +#include "nsThreadUtils.h" #include "mozilla/dom/quota/QuotaManager.h" USING_INDEXEDDB_NAMESPACE diff --git a/dom/indexedDB/FileInfo.h b/dom/indexedDB/FileInfo.h index e79e763260a7..51512e01ce22 100644 --- a/dom/indexedDB/FileInfo.h +++ b/dom/indexedDB/FileInfo.h @@ -9,8 +9,6 @@ #include "IndexedDatabase.h" -#include "nsThreadUtils.h" - #include "FileManager.h" #include "IndexedDatabaseManager.h" diff --git a/dom/plugins/ipc/PluginHangUIParent.cpp b/dom/plugins/ipc/PluginHangUIParent.cpp index bf479a4ba5da..a97ce333f8b6 100644 --- a/dom/plugins/ipc/PluginHangUIParent.cpp +++ b/dom/plugins/ipc/PluginHangUIParent.cpp @@ -18,6 +18,7 @@ #include "nsIWindowMediator.h" #include "nsIWinTaskbar.h" #include "nsServiceManagerUtils.h" +#include "nsThreadUtils.h" #include "WidgetUtils.h" diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index 23da0f233ed8..c2ae48cf61a5 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -20,7 +20,6 @@ #include "nsAutoPtr.h" #include "nsStringGlue.h" #include "nsTArray.h" -#include "nsThreadUtils.h" #include "prlog.h" #include "nsHashKeys.h" #ifdef MOZ_CRASHREPORTER diff --git a/dom/quota/QuotaManager.h b/dom/quota/QuotaManager.h index 388c24f40118..dadc938b3b7b 100644 --- a/dom/quota/QuotaManager.h +++ b/dom/quota/QuotaManager.h @@ -17,7 +17,6 @@ #include "nsClassHashtable.h" #include "nsRefPtrHashtable.h" -#include "nsThreadUtils.h" #include "ArrayCluster.h" #include "Client.h" @@ -33,6 +32,7 @@ class nsIThread; class nsITimer; class nsIURI; class nsPIDOMWindow; +class nsIRunnable; BEGIN_QUOTA_NAMESPACE diff --git a/dom/src/notification/DesktopNotification.h b/dom/src/notification/DesktopNotification.h index 90a026a888ed..e35f7f4fddca 100644 --- a/dom/src/notification/DesktopNotification.h +++ b/dom/src/notification/DesktopNotification.h @@ -15,7 +15,6 @@ #include "nsCycleCollectionParticipant.h" #include "nsIDOMWindow.h" #include "nsIScriptObjectPrincipal.h" -#include "nsThreadUtils.h" #include "nsDOMEventTargetHelper.h" #include "nsIDOMEvent.h" diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index e36bec1f8526..996ca4a8842c 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -25,7 +25,6 @@ #include "nsRect.h" // for nsIntRect #include "nsSize.h" // for nsIntSize #include "nsTArray.h" // for nsTArray -#include "nsThreadUtils.h" // for NS_IsMainThread #include "mozilla/Atomics.h" class nsMainThreadSurfaceRef; @@ -817,7 +816,6 @@ public: virtual already_AddRefed GetAsSurface() { - NS_ASSERTION(NS_IsMainThread(), "Must be main thread"); nsRefPtr surface = mSurface.get(); return surface.forget(); } diff --git a/gfx/thebes/gfxFontUtils.h b/gfx/thebes/gfxFontUtils.h index 5a8f6b41780a..03b07745ff92 100644 --- a/gfx/thebes/gfxFontUtils.h +++ b/gfx/thebes/gfxFontUtils.h @@ -16,8 +16,6 @@ #include "nsITimer.h" #include "nsCOMPtr.h" -#include "nsIRunnable.h" -#include "nsThreadUtils.h" #include "nsComponentManagerUtils.h" #include "nsTArray.h" #include "nsAutoPtr.h" diff --git a/media/mtransport/transportflow.h b/media/mtransport/transportflow.h index 8add5eb1dff2..a553050d6cf7 100644 --- a/media/mtransport/transportflow.h +++ b/media/mtransport/transportflow.h @@ -18,6 +18,7 @@ #include "mozilla/Scoped.h" #include "transportlayer.h" #include "m_cpp_utils.h" +#include "nsAutoPtr.h" // A stack of transport layers acts as a flow. // Generally, one reads and writes to the top layer. diff --git a/media/mtransport/transportlayer.cpp b/media/mtransport/transportlayer.cpp index c851bae2388d..a31ebef4077f 100644 --- a/media/mtransport/transportlayer.cpp +++ b/media/mtransport/transportlayer.cpp @@ -8,6 +8,7 @@ #include "logging.h" #include "transportflow.h" #include "transportlayer.h" +#include "nsThreadUtils.h" // Logging context namespace mozilla { @@ -46,4 +47,19 @@ void TransportLayer::SetState(State state) { } } +nsresult TransportLayer::RunOnThread(nsIRunnable *event) { + if (target_) { + nsIThread *thr; + + DebugOnly rv = NS_GetCurrentThread(&thr); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + + if (target_ != thr) { + return target_->Dispatch(event, NS_DISPATCH_SYNC); + } + } + + return event->Run(); +} + } // close namespace diff --git a/media/mtransport/transportlayer.h b/media/mtransport/transportlayer.h index d523d62e0a2e..f018a8f44181 100644 --- a/media/mtransport/transportlayer.h +++ b/media/mtransport/transportlayer.h @@ -15,7 +15,6 @@ #include "mozilla/RefPtr.h" #include "nsCOMPtr.h" #include "nsIEventTarget.h" -#include "nsThreadUtils.h" #include "m_cpp_utils.h" @@ -62,20 +61,7 @@ class TransportLayer : public sigslot::has_slots<> { // Dispatch a call onto our thread (or run on the same thread if // thread is not set). This is always synchronous. - nsresult RunOnThread(nsIRunnable *event) { - if (target_) { - nsIThread *thr; - - DebugOnly rv = NS_GetCurrentThread(&thr); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - - if (target_ != thr) { - return target_->Dispatch(event, NS_DISPATCH_SYNC); - } - } - - return event->Run(); - } + nsresult RunOnThread(nsIRunnable *event); // Get the state State state() const { return state_; } diff --git a/mobile/android/components/build/nsAndroidHistory.cpp b/mobile/android/components/build/nsAndroidHistory.cpp index ac0dc4ff8666..8bcc1dee65fe 100644 --- a/mobile/android/components/build/nsAndroidHistory.cpp +++ b/mobile/android/components/build/nsAndroidHistory.cpp @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "nsThreadUtils.h" #include "nsAndroidHistory.h" #include "AndroidBridge.h" #include "Link.h" diff --git a/mobile/android/components/build/nsAndroidHistory.h b/mobile/android/components/build/nsAndroidHistory.h index 2ec5d8577771..7e8c03286ed2 100644 --- a/mobile/android/components/build/nsAndroidHistory.h +++ b/mobile/android/components/build/nsAndroidHistory.h @@ -9,7 +9,7 @@ #include "IHistory.h" #include "nsDataHashtable.h" #include "nsTPriorityQueue.h" -#include "nsThreadUtils.h" +#include "nsIRunnable.h" #define NS_ANDROIDHISTORY_CID \ {0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}} diff --git a/netwerk/base/src/Dashboard.cpp b/netwerk/base/src/Dashboard.cpp index c4232b071336..115c6a0c3a2a 100644 --- a/netwerk/base/src/Dashboard.cpp +++ b/netwerk/base/src/Dashboard.cpp @@ -10,6 +10,7 @@ #include "nsIDNSService.h" #include "nsIThread.h" #include "nsSocketTransport2.h" +#include "nsThreadUtils.h" using mozilla::AutoSafeJSContext; namespace mozilla { diff --git a/netwerk/base/src/EventTokenBucket.cpp b/netwerk/base/src/EventTokenBucket.cpp index 525dfc1582ab..aa09670992aa 100644 --- a/netwerk/base/src/EventTokenBucket.cpp +++ b/netwerk/base/src/EventTokenBucket.cpp @@ -8,6 +8,7 @@ #include "nsNetUtil.h" #include "nsSocketTransportService2.h" +#include "nsThreadUtils.h" #ifdef XP_WIN #include diff --git a/netwerk/base/src/Tickler.cpp b/netwerk/base/src/Tickler.cpp index 392d68eb50f7..0b240fc4cafc 100644 --- a/netwerk/base/src/Tickler.cpp +++ b/netwerk/base/src/Tickler.cpp @@ -9,6 +9,7 @@ #include "nsServiceManagerUtils.h" #include "prnetdb.h" #include "Tickler.h" +#include "nsThreadUtils.h" #ifdef MOZ_USE_WIFI_TICKLER diff --git a/netwerk/base/src/Tickler.h b/netwerk/base/src/Tickler.h index f8af5f934193..75f42ae2441f 100644 --- a/netwerk/base/src/Tickler.h +++ b/netwerk/base/src/Tickler.h @@ -32,7 +32,6 @@ #include "nsAutoPtr.h" #include "nsISupports.h" #include "nsIThread.h" -#include "nsThreadUtils.h" #include "nsITimer.h" #include "nsWeakReference.h" diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index 6c00641561be..5160f112d7b1 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -26,7 +26,7 @@ #include "prerr.h" #include "NetworkActivityMonitor.h" #include "mozilla/VisualEventTracer.h" - +#include "nsThreadUtils.h" #include "nsIServiceManager.h" #include "nsISocketProviderService.h" #include "nsISocketProvider.h" diff --git a/netwerk/base/src/nsSocketTransportService2.cpp b/netwerk/base/src/nsSocketTransportService2.cpp index 4caa6aa1c247..ae5908571518 100644 --- a/netwerk/base/src/nsSocketTransportService2.cpp +++ b/netwerk/base/src/nsSocketTransportService2.cpp @@ -24,6 +24,7 @@ #include "mozilla/Preferences.h" #include "mozilla/Likely.h" #include "mozilla/PublicSSL.h" +#include "nsThreadUtils.h" using namespace mozilla; using namespace mozilla::net; diff --git a/netwerk/base/src/nsSocketTransportService2.h b/netwerk/base/src/nsSocketTransportService2.h index 4797ab73babf..5150a2e3f6e6 100644 --- a/netwerk/base/src/nsSocketTransportService2.h +++ b/netwerk/base/src/nsSocketTransportService2.h @@ -8,7 +8,7 @@ #include "nsPISocketTransportService.h" #include "nsIThreadInternal.h" -#include "nsThreadUtils.h" +#include "nsIRunnable.h" #include "nsEventQueue.h" #include "nsCOMPtr.h" #include "pldhash.h" diff --git a/netwerk/base/src/nsUDPServerSocket.h b/netwerk/base/src/nsUDPServerSocket.h index 183ac7f9f939..1f65ad152a91 100644 --- a/netwerk/base/src/nsUDPServerSocket.h +++ b/netwerk/base/src/nsUDPServerSocket.h @@ -10,6 +10,7 @@ #include "nsSocketTransportService2.h" #include "mozilla/Mutex.h" #include "nsIOutputStream.h" +#include "nsAutoPtr.h" //----------------------------------------------------------------------------- diff --git a/netwerk/ipc/ChannelEventQueue.cpp b/netwerk/ipc/ChannelEventQueue.cpp index 49682a81c372..eac17c182109 100644 --- a/netwerk/ipc/ChannelEventQueue.cpp +++ b/netwerk/ipc/ChannelEventQueue.cpp @@ -7,6 +7,7 @@ #include "nsISupports.h" #include "mozilla/net/ChannelEventQueue.h" +#include "nsThreadUtils.h" namespace mozilla { namespace net { @@ -41,6 +42,21 @@ ChannelEventQueue::FlushQueue() mFlushing = false; } +void +ChannelEventQueue::Resume() +{ + // Resuming w/o suspend: error in debug mode, ignore in build + MOZ_ASSERT(mSuspendCount > 0); + if (mSuspendCount <= 0) { + return; + } + + if (!--mSuspendCount) { + nsRefPtr > event = + NS_NewRunnableMethod(this, &ChannelEventQueue::CompleteResume); + NS_DispatchToCurrentThread(event); + } +} } } diff --git a/netwerk/ipc/ChannelEventQueue.h b/netwerk/ipc/ChannelEventQueue.h index 0350514d1cd0..87c58afe44b9 100644 --- a/netwerk/ipc/ChannelEventQueue.h +++ b/netwerk/ipc/ChannelEventQueue.h @@ -10,7 +10,6 @@ #include #include -#include class nsISupports; @@ -70,7 +69,7 @@ class ChannelEventQueue inline void Suspend(); // Resume flushes the queue asynchronously, i.e. items in queue will be // dispatched in a new event on the current thread. - inline void Resume(); + void Resume(); private: inline void MaybeFlushQueue(); @@ -140,22 +139,6 @@ ChannelEventQueue::CompleteResume() } } -inline void -ChannelEventQueue::Resume() -{ - // Resuming w/o suspend: error in debug mode, ignore in build - MOZ_ASSERT(mSuspendCount > 0); - if (mSuspendCount <= 0) { - return; - } - - if (!--mSuspendCount) { - nsRefPtr > event = - NS_NewRunnableMethod(this, &ChannelEventQueue::CompleteResume); - NS_DispatchToCurrentThread(event); - } -} - inline void ChannelEventQueue::MaybeFlushQueue() { diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 3ce92220126f..88e25ef7c097 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -11,7 +11,6 @@ #include "nsHttpTransaction.h" #include "nsInputStreamPump.h" -#include "nsThreadUtils.h" #include "nsTArray.h" #include "nsIHttpEventSink.h" diff --git a/parser/html/nsHtml5Parser.h b/parser/html/nsHtml5Parser.h index a46448e33ca3..bce099e75152 100644 --- a/parser/html/nsHtml5Parser.h +++ b/parser/html/nsHtml5Parser.h @@ -12,7 +12,6 @@ #include "nsIURL.h" #include "nsParserCIID.h" #include "nsITokenizer.h" -#include "nsThreadUtils.h" #include "nsIContentSink.h" #include "nsIRequest.h" #include "nsIChannel.h" diff --git a/storage/src/mozStorageAsyncStatementExecution.h b/storage/src/mozStorageAsyncStatementExecution.h index 4553339826a0..19ab6bf8b19b 100644 --- a/storage/src/mozStorageAsyncStatementExecution.h +++ b/storage/src/mozStorageAsyncStatementExecution.h @@ -10,10 +10,10 @@ #include "nscore.h" #include "nsTArray.h" #include "nsAutoPtr.h" -#include "nsThreadUtils.h" #include "mozilla/Mutex.h" #include "mozilla/TimeStamp.h" #include "mozilla/Attributes.h" +#include "nsIRunnable.h" #include "SQLiteMutex.h" #include "mozIStoragePendingStatement.h" diff --git a/toolkit/components/places/nsNavHistory.h b/toolkit/components/places/nsNavHistory.h index 29686651af8b..15754b2b04e3 100644 --- a/toolkit/components/places/nsNavHistory.h +++ b/toolkit/components/places/nsNavHistory.h @@ -21,7 +21,6 @@ #include "nsCategoryCache.h" #include "nsNetCID.h" #include "nsToolkitCompsCID.h" -#include "nsThreadUtils.h" #include "nsURIHashKey.h" #include "nsTHashtable.h" diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h index c2a158056e03..343f1b22d8dd 100644 --- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -13,9 +13,6 @@ #include "nsCOMPtr.h" #include "nsCOMArray.h" -#include "nsIRunnable.h" -#include "nsIObserver.h" -#include "nsThreadUtils.h" #include "AndroidJavaWrappers.h" @@ -38,6 +35,7 @@ class nsWindow; class nsIDOMMozSmsMessage; +class nsIObserver; /* See the comment in AndroidBridge about this function before using it */ extern "C" JNIEnv * GetJNIForThread(); diff --git a/widget/windows/JumpListBuilder.h b/widget/windows/JumpListBuilder.h index d346b4a817e0..2c32fb656492 100644 --- a/widget/windows/JumpListBuilder.h +++ b/widget/windows/JumpListBuilder.h @@ -20,7 +20,6 @@ #include "nsIJumpListItem.h" #include "JumpListItem.h" #include "nsIObserver.h" -#include "nsThreadUtils.h" #include "mozilla/Attributes.h" namespace mozilla { diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 8ff4bf3002d3..e86acb4854eb 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -27,6 +27,7 @@ #include "nsIChannel.h" #include "nsIObserver.h" #include "imgIEncoder.h" +#include "nsIThread.h" #ifdef NS_ENABLE_TSF #include diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index a71e6a7cdb54..0e6ae2113d79 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -15,7 +15,7 @@ #include "nsString.h" #include "nsRegion.h" -#include "nsThreadUtils.h" +#include "nsIRunnable.h" #include "nsICryptoHash.h" #ifdef MOZ_PLACES #include "nsIFaviconService.h" @@ -30,6 +30,7 @@ class nsWindow; class nsWindowBase; struct KeyPair; struct nsIntRect; +class nsIThread; namespace mozilla { namespace widget { diff --git a/widget/windows/nsSound.cpp b/widget/windows/nsSound.cpp index a5ad2341390d..0813412b73b2 100644 --- a/widget/windows/nsSound.cpp +++ b/widget/windows/nsSound.cpp @@ -24,6 +24,7 @@ #include "prmem.h" #include "nsNativeCharsetUtils.h" +#include "nsThreadUtils.h" #ifdef PR_LOGGING PRLogModuleInfo* gWin32SoundLog = nullptr; diff --git a/widget/windows/nsSound.h b/widget/windows/nsSound.h index f423a6ec57e4..f8344c192e57 100644 --- a/widget/windows/nsSound.h +++ b/widget/windows/nsSound.h @@ -9,7 +9,9 @@ #include "nsISound.h" #include "nsIStreamLoader.h" -#include "nsThreadUtils.h" +#include "nsCOMPtr.h" + +class nsIThread; class nsSound : public nsISound, public nsIStreamLoaderObserver From ba61b1281ed5b6b1ac7b09448ec2d1ce8c07c9e0 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 19 Sep 2013 09:54:41 -0400 Subject: [PATCH 16/43] Bug 913847 - split NS_IsMainThread and NS_GetMainThread into a new MainThreadUtils.h header - r=ehsan --- xpcom/glue/MainThreadUtils.h | 50 ++++++++++++++++++++++++++++++++++++ xpcom/glue/moz.build | 1 + xpcom/glue/nsThreadUtils.h | 38 +-------------------------- 3 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 xpcom/glue/MainThreadUtils.h diff --git a/xpcom/glue/MainThreadUtils.h b/xpcom/glue/MainThreadUtils.h new file mode 100644 index 000000000000..c1d24011b72a --- /dev/null +++ b/xpcom/glue/MainThreadUtils.h @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MainThreadUtils_h_ +#define MainThreadUtils_h_ + +#include "nscore.h" +#include "mozilla/threads/nsThreadIDs.h" + +class nsIThread; + +/** + * Get a reference to the main thread. + * + * @param result + * The resulting nsIThread object. + */ +extern NS_COM_GLUE NS_METHOD +NS_GetMainThread(nsIThread **result); + +#if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN) +bool NS_IsMainThread(); +#elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS) +// This is defined in nsThreadManager.cpp and initialized to `Main` for the +// main thread by nsThreadManager::Init. +extern NS_TLS mozilla::threads::ID gTLSThreadID; +#ifdef MOZ_ASAN +// Temporary workaround, see bug 895845 +MOZ_ASAN_BLACKLIST static +#else +inline +#endif +bool NS_IsMainThread() +{ + return gTLSThreadID == mozilla::threads::Main; +} +#else +/** + * Test to see if the current thread is the main thread. + * + * @returns true if the current thread is the main thread, and false + * otherwise. + */ +extern NS_COM_GLUE bool NS_IsMainThread(); +#endif + +#endif // MainThreadUtils_h_ diff --git a/xpcom/glue/moz.build b/xpcom/glue/moz.build index ff9e3ebdf98a..c79904650ae3 100644 --- a/xpcom/glue/moz.build +++ b/xpcom/glue/moz.build @@ -14,6 +14,7 @@ if CONFIG['OS_ARCH'] == 'WINNT': MODULE = 'xpcom' EXPORTS += [ + 'MainThreadUtils.h', 'nsArrayEnumerator.h', 'nsArrayUtils.h', 'nsBaseHashtable.h', diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h index 82a555766c53..e53cc013153c 100644 --- a/xpcom/glue/nsThreadUtils.h +++ b/xpcom/glue/nsThreadUtils.h @@ -9,7 +9,7 @@ #include "prthread.h" #include "prinrval.h" -#include "nscore.h" +#include "MainThreadUtils.h" #include "nsIThreadManager.h" #include "nsIThread.h" #include "nsIRunnable.h" @@ -17,7 +17,6 @@ #include "nsStringGlue.h" #include "nsCOMPtr.h" #include "nsAutoPtr.h" -#include "mozilla/threads/nsThreadIDs.h" #include "mozilla/Likely.h" //----------------------------------------------------------------------------- @@ -91,41 +90,6 @@ NS_NewNamedThread(const char (&name)[LEN], extern NS_COM_GLUE NS_METHOD NS_GetCurrentThread(nsIThread **result); -/** - * Get a reference to the main thread. - * - * @param result - * The resulting nsIThread object. - */ -extern NS_COM_GLUE NS_METHOD -NS_GetMainThread(nsIThread **result); - -#if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN) -bool NS_IsMainThread(); -#elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS) -// This is defined in nsThreadManager.cpp and initialized to `Main` for the -// main thread by nsThreadManager::Init. -extern NS_TLS mozilla::threads::ID gTLSThreadID; -#ifdef MOZ_ASAN -// Temporary workaround, see bug 895845 -MOZ_ASAN_BLACKLIST static -#else -inline -#endif -bool NS_IsMainThread() -{ - return gTLSThreadID == mozilla::threads::Main; -} -#else -/** - * Test to see if the current thread is the main thread. - * - * @returns true if the current thread is the main thread, and false - * otherwise. - */ -extern NS_COM_GLUE bool NS_IsMainThread(); -#endif - /** * Dispatch the given event to the current thread. * From 229d2760cd64b1e8ca49bb567697a6b16be824d2 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 19 Sep 2013 09:54:42 -0400 Subject: [PATCH 17/43] Bug 913847 - Include MainThreadUtils.h instead of nsThreadUtils.h - r=ehsan --- content/events/src/nsDOMEventTargetHelper.h | 2 +- content/media/MediaStreamGraph.h | 4 +++- dom/bindings/BindingUtils.h | 2 +- dom/indexedDB/IDBObjectStore.h | 2 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 1 + dom/plugins/base/nsPluginHost.h | 2 +- dom/src/storage/DOMStorageCache.cpp | 1 + js/xpconnect/src/xpcprivate.h | 2 +- layout/build/nsLayoutStatics.h | 4 +++- netwerk/base/src/nsServerSocket.cpp | 1 + netwerk/base/src/nsUDPServerSocket.cpp | 1 + netwerk/protocol/http/nsHttpTransaction.h | 2 +- netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp | 1 + security/manager/ssl/src/nsNSSComponent.cpp | 1 + storage/src/mozStorageStatementData.h | 2 +- toolkit/components/places/AsyncFaviconHelpers.h | 1 + toolkit/components/places/Database.h | 4 +++- xpcom/base/ClearOnShutdown.h | 2 +- xpcom/glue/nsProxyRelease.h | 5 +++-- 19 files changed, 27 insertions(+), 13 deletions(-) diff --git a/content/events/src/nsDOMEventTargetHelper.h b/content/events/src/nsDOMEventTargetHelper.h index 58470ca30423..7d39550b7400 100644 --- a/content/events/src/nsDOMEventTargetHelper.h +++ b/content/events/src/nsDOMEventTargetHelper.h @@ -13,7 +13,7 @@ #include "nsIScriptGlobalObject.h" #include "nsEventListenerManager.h" #include "nsIScriptContext.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "mozilla/Attributes.h" #include "mozilla/dom/EventTarget.h" diff --git a/content/media/MediaStreamGraph.h b/content/media/MediaStreamGraph.h index 82598370336b..1d6cfc25932a 100644 --- a/content/media/MediaStreamGraph.h +++ b/content/media/MediaStreamGraph.h @@ -15,7 +15,9 @@ #include "TimeVarying.h" #include "VideoFrameContainer.h" #include "VideoSegment.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" + +class nsIRunnable; namespace mozilla { diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index c512958870c4..55a134a4c912 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -23,7 +23,7 @@ #include "mozilla/Util.h" #include "nsCycleCollector.h" #include "nsIXPConnect.h" -#include "nsThreadUtils.h" // Hacky work around for some bindings needing NS_IsMainThread. +#include "MainThreadUtils.h" #include "nsTraceRefcnt.h" #include "qsObjectHelper.h" #include "xpcpublic.h" diff --git a/dom/indexedDB/IDBObjectStore.h b/dom/indexedDB/IDBObjectStore.h index c96fea3c10aa..86f225f84225 100644 --- a/dom/indexedDB/IDBObjectStore.h +++ b/dom/indexedDB/IDBObjectStore.h @@ -13,7 +13,7 @@ #include "mozilla/dom/IDBIndexBinding.h" #include "mozilla/dom/IDBObjectStoreBinding.h" #include "nsCycleCollectionParticipant.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "mozilla/dom/indexedDB/IDBRequest.h" #include "mozilla/dom/indexedDB/IDBTransaction.h" diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 97096b55ba44..1259ce45ccc2 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -23,6 +23,7 @@ #include "nsContentUtils.h" #include "nsPluginInstanceOwner.h" +#include "nsThreadUtils.h" #include "nsIDOMElement.h" #include "nsIDocument.h" #include "nsIDocShell.h" diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h index 06b576a8b00a..ef173c064127 100644 --- a/dom/plugins/base/nsPluginHost.h +++ b/dom/plugins/base/nsPluginHost.h @@ -19,7 +19,7 @@ #include "nsWeakPtr.h" #include "nsIPrompt.h" #include "nsWeakReference.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "nsTArray.h" #include "nsTObserverArray.h" #include "nsITimer.h" diff --git a/dom/src/storage/DOMStorageCache.cpp b/dom/src/storage/DOMStorageCache.cpp index c5a8ef24ba08..813e2a6fac5b 100644 --- a/dom/src/storage/DOMStorageCache.cpp +++ b/dom/src/storage/DOMStorageCache.cpp @@ -14,6 +14,7 @@ #include "nsXULAppAPI.h" #include "mozilla/unused.h" #include "nsProxyRelease.h" +#include "nsThreadUtils.h" namespace mozilla { namespace dom { diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 2f9dfbb7871e..c29c3394ba9b 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -127,7 +127,7 @@ #include "nsXPIDLString.h" #include "nsAutoJSValHolder.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "nsIJSEngineTelemetryStats.h" #include "nsIConsoleService.h" diff --git a/layout/build/nsLayoutStatics.h b/layout/build/nsLayoutStatics.h index ca8510c73d85..bdb11303cc70 100644 --- a/layout/build/nsLayoutStatics.h +++ b/layout/build/nsLayoutStatics.h @@ -6,7 +6,9 @@ #define nsLayoutStatics_h__ #include "nscore.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" +#include "nsTraceRefcnt.h" +#include "nsDebug.h" // This isn't really a class, it's a namespace for static methods. // Documents and other objects can hold a reference to the layout static diff --git a/netwerk/base/src/nsServerSocket.cpp b/netwerk/base/src/nsServerSocket.cpp index 95a7c4350692..2e79d3ad9cdc 100644 --- a/netwerk/base/src/nsServerSocket.cpp +++ b/netwerk/base/src/nsServerSocket.cpp @@ -12,6 +12,7 @@ #include "nsNetCID.h" #include "prnetdb.h" #include "prio.h" +#include "nsThreadUtils.h" #include "mozilla/Attributes.h" #include "mozilla/net/DNS.h" diff --git a/netwerk/base/src/nsUDPServerSocket.cpp b/netwerk/base/src/nsUDPServerSocket.cpp index 6a2d9ede1b23..3bf844ecb89f 100644 --- a/netwerk/base/src/nsUDPServerSocket.cpp +++ b/netwerk/base/src/nsUDPServerSocket.cpp @@ -20,6 +20,7 @@ #include "nsIPipe.h" #include "prerror.h" #include "nsINSSErrorsService.h" +#include "nsThreadUtils.h" using namespace mozilla::net; using namespace mozilla; diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index f0b61a2f44f2..de74ff871340 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -12,7 +12,7 @@ #include "nsAHttpConnection.h" #include "EventTokenBucket.h" #include "nsCOMPtr.h" - +#include "nsThreadUtils.h" #include "nsIPipe.h" #include "nsIInputStream.h" #include "nsILoadGroup.h" diff --git a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp index 932b2808bade..717eac1e6b37 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp @@ -14,6 +14,7 @@ #include "nsICacheSession.h" #include "nsCharsetSource.h" #include "nsProxyRelease.h" +#include "nsThreadUtils.h" // Must release mChannel on the main thread class nsWyciwygAsyncEvent : public nsRunnable { diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp index 1420574631bc..78a156296453 100644 --- a/security/manager/ssl/src/nsNSSComponent.cpp +++ b/security/manager/ssl/src/nsNSSComponent.cpp @@ -17,6 +17,7 @@ #include "nsDirectoryServiceDefs.h" #include "nsICertOverrideService.h" #include "mozilla/Preferences.h" +#include "nsThreadUtils.h" #ifndef MOZ_DISABLE_CRYPTOLEGACY #include "nsIDOMNode.h" diff --git a/storage/src/mozStorageStatementData.h b/storage/src/mozStorageStatementData.h index 71db5473c87d..2e611cd3c1e5 100644 --- a/storage/src/mozStorageStatementData.h +++ b/storage/src/mozStorageStatementData.h @@ -13,7 +13,7 @@ #include "nsTArray.h" #include "nsIEventTarget.h" #include "mozilla/Util.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "mozStorageBindingParamsArray.h" #include "mozIStorageBaseStatement.h" diff --git a/toolkit/components/places/AsyncFaviconHelpers.h b/toolkit/components/places/AsyncFaviconHelpers.h index 338453428000..0aa0ef97ca79 100644 --- a/toolkit/components/places/AsyncFaviconHelpers.h +++ b/toolkit/components/places/AsyncFaviconHelpers.h @@ -11,6 +11,7 @@ #include "nsIChannelEventSink.h" #include "nsIInterfaceRequestor.h" #include "nsIStreamListener.h" +#include "nsThreadUtils.h" #include "Database.h" #include "mozilla/storage.h" diff --git a/toolkit/components/places/Database.h b/toolkit/components/places/Database.h index 79cbcc89994c..cb0f0c508662 100644 --- a/toolkit/components/places/Database.h +++ b/toolkit/components/places/Database.h @@ -5,13 +5,14 @@ #ifndef mozilla_places_Database_h_ #define mozilla_places_Database_h_ -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "nsWeakReference.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIObserver.h" #include "mozilla/storage.h" #include "mozilla/storage/StatementCache.h" #include "mozilla/Attributes.h" +#include "nsIEventTarget.h" // This is the schema version. Update it at any schema change and add a // corresponding migrateVxx method below. @@ -43,6 +44,7 @@ #define TOPIC_PLACES_CONNECTION_CLOSED "places-connection-closed" class nsIStringBundle; +class nsIRunnable; namespace mozilla { namespace places { diff --git a/xpcom/base/ClearOnShutdown.h b/xpcom/base/ClearOnShutdown.h index 4bc4aaaa0865..7dc9cde419a4 100644 --- a/xpcom/base/ClearOnShutdown.h +++ b/xpcom/base/ClearOnShutdown.h @@ -9,7 +9,7 @@ #include "mozilla/LinkedList.h" #include "mozilla/StaticPtr.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" /* * This header exports one public method in the mozilla namespace: diff --git a/xpcom/glue/nsProxyRelease.h b/xpcom/glue/nsProxyRelease.h index e6dae7eb5de4..c4f7ad0ceaa2 100644 --- a/xpcom/glue/nsProxyRelease.h +++ b/xpcom/glue/nsProxyRelease.h @@ -9,7 +9,7 @@ #include "nsIEventTarget.h" #include "nsCOMPtr.h" #include "nsAutoPtr.h" -#include "nsThreadUtils.h" +#include "MainThreadUtils.h" #include "mozilla/Likely.h" #ifdef XPCOM_GLUE_AVOID_NSPR @@ -122,7 +122,8 @@ public: if (NS_IsMainThread()) { NS_IF_RELEASE(mRawPtr); } else if (mRawPtr) { - nsCOMPtr mainThread = do_GetMainThread(); + nsCOMPtr mainThread; + NS_GetMainThread(getter_AddRefs(mainThread)); if (!mainThread) { NS_WARNING("Couldn't get main thread! Leaking pointer."); return; From ce31715bd968c14f09deeaed4a105f32ce9c7a06 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Wed, 18 Sep 2013 10:22:12 -0500 Subject: [PATCH 18/43] Bug 900669 - OdinMonkey: use RelativeLink to patch x86 global references (r=bbouvier) --HG-- extra : rebase_source : 99ddf49abbb58e6454a9e8f188a0849fc07be89a --- js/src/jit/AsmJS.cpp | 23 ++++++++++++++++++----- js/src/jit/MIRGenerator.h | 12 ------------ js/src/jit/shared/Assembler-shared.h | 12 ++++++++++++ js/src/jit/x64/MacroAssembler-x64.h | 4 ++-- js/src/jit/x86/MacroAssembler-x86.h | 10 ---------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index c53ab4b636f3..07582bb43a21 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -1766,15 +1766,28 @@ class MOZ_STACK_CLASS ModuleCompiler } } - // Global-data-section accesses -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CPU_X86) + // Global data accesses in x86 need to be patched with the absolute + // address of the global. Globals are allocated sequentially after the + // code section so we can just use an RelativeLink. + for (unsigned i = 0; i < globalAccesses_.length(); i++) { + AsmJSGlobalAccess a = globalAccesses_[i]; + AsmJSStaticLinkData::RelativeLink link; + link.patchAtOffset = masm_.labelOffsetToPatchOffset(a.patchAt.offset()); + link.targetOffset = module_->offsetOfGlobalData() + a.globalDataOffset; + if (!linkData->relativeLinks.append(link)) + return false; + } +#endif + +#if defined(JS_CPU_X64) + // Global data accesses on x64 use rip-relative addressing and thus do + // not need patching after deserialization. uint8_t *code = module_->codeBase(); for (unsigned i = 0; i < globalAccesses_.length(); i++) { AsmJSGlobalAccess a = globalAccesses_[i]; - masm_.patchAsmJSGlobalAccess(a.offset, code, module_->globalData(), a.globalDataOffset); + masm_.patchAsmJSGlobalAccess(a.patchAt, code, module_->globalData(), a.globalDataOffset); } -#else - JS_ASSERT(globalAccesses_.empty()); #endif *module = module_.forget(); diff --git a/js/src/jit/MIRGenerator.h b/js/src/jit/MIRGenerator.h index 91a4ee365ba4..a75d28cf2368 100644 --- a/js/src/jit/MIRGenerator.h +++ b/js/src/jit/MIRGenerator.h @@ -28,18 +28,6 @@ class MBasicBlock; class MIRGraph; class MStart; -struct AsmJSGlobalAccess -{ - unsigned offset; - unsigned globalDataOffset; - - AsmJSGlobalAccess(unsigned offset, unsigned globalDataOffset) - : offset(offset), globalDataOffset(globalDataOffset) - {} -}; - -typedef Vector AsmJSGlobalAccessVector; - class MIRGenerator { public: diff --git a/js/src/jit/shared/Assembler-shared.h b/js/src/jit/shared/Assembler-shared.h index 40a283f547d6..7b072ab0932e 100644 --- a/js/src/jit/shared/Assembler-shared.h +++ b/js/src/jit/shared/Assembler-shared.h @@ -613,6 +613,18 @@ class CodeLocationLabel } }; +struct AsmJSGlobalAccess +{ + CodeOffsetLabel patchAt; + unsigned globalDataOffset; + + AsmJSGlobalAccess(CodeOffsetLabel patchAt, unsigned globalDataOffset) + : patchAt(patchAt), globalDataOffset(globalDataOffset) + {} +}; + +typedef Vector AsmJSGlobalAccessVector; + } // namespace jit } // namespace js diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 4572d9f67834..a5cdbbbc5ace 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -1174,10 +1174,10 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared } // See CodeGeneratorX64 calls to noteAsmJSGlobalAccess. - void patchAsmJSGlobalAccess(unsigned offset, uint8_t *code, uint8_t *globalData, + void patchAsmJSGlobalAccess(CodeOffsetLabel patchAt, uint8_t *code, uint8_t *globalData, unsigned globalDataOffset) { - uint8_t *nextInsn = code + offset; + uint8_t *nextInsn = code + patchAt.offset(); JS_ASSERT(nextInsn <= globalData); uint8_t *target = globalData + globalDataOffset; ((int32_t *)nextInsn)[-1] = target - nextInsn; diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 9e9ed7047196..1c85f9bb776f 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -1065,16 +1065,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared call(code); addl(Imm32(sizeof(uintptr_t) * 2), esp); } - - // See CodeGeneratorX86 calls to noteAsmJSGlobalAccess. - void patchAsmJSGlobalAccess(unsigned offset, uint8_t *code, uint8_t *globalData, - unsigned globalDataOffset) - { - uint8_t *nextInsn = code + offset; - JS_ASSERT(nextInsn <= globalData); - uint8_t *target = globalData + globalDataOffset; - ((int32_t *)nextInsn)[-1] = uintptr_t(target); - } }; typedef MacroAssemblerX86 MacroAssemblerSpecific; From da985be9dbb52396a7cc6232145baca91732bb59 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 13:46:26 +0100 Subject: [PATCH 19/43] Bug 918299 - Disable content/media/test/* mochitest timeouts on B2G for causing mochitest-3 runs to abort midway through --HG-- extra : rebase_source : 06d5097efac8ff1197216c2b87709f50b5c39f26 --- testing/mochitest/b2g.json | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/mochitest/b2g.json b/testing/mochitest/b2g.json index 6809508d5c63..92fc3f651ead 100644 --- a/testing/mochitest/b2g.json +++ b/testing/mochitest/b2g.json @@ -15,6 +15,7 @@ "layout/forms/test/test_bug478219.xhtml":"window.closed not working, bug 907795", + "content/media/test":"bug 918299", "content/media/test/test_bug448534.html": "Timed out, bug 894922? Bug 902677 is for the timing out of a lot of media tests", "content/media/mediasource/test/test_MediaSource.html": " ReferenceError: MediaSource is not defined", "content/media/test/test_autoplay_contentEditable.html": "bug 899074 - timeouts", From b08c7934ac80f8b4cd6d83f45990a93568903fa0 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 13:53:28 +0100 Subject: [PATCH 20/43] Bug 719186 - Disable test_bug413310.html for too many intermittent failures --HG-- extra : rebase_source : 94e1e52bf42254e06ea2514e91da3bb8cc5c33b7 --- docshell/test/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docshell/test/Makefile.in b/docshell/test/Makefile.in index 07b7788272ef..09c534342a98 100644 --- a/docshell/test/Makefile.in +++ b/docshell/test/Makefile.in @@ -3,6 +3,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# Disabled for too many intermittent failures (bug 719186) +# test_bug413310.html \ + MOCHITEST_FILES = \ test_bug123696.html \ bug123696-subframe.html \ @@ -13,7 +16,6 @@ MOCHITEST_FILES = \ test_bug387979.html \ test_bug404548.html \ bug404548-subframe.html \ - test_bug413310.html \ bug413310-subframe.html \ bug413310-post.sjs \ test_bug402210.html \ From 1a880817ee27f452310f2376cc8d97b30c39477a Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 14:06:16 +0100 Subject: [PATCH 21/43] Bug 859075 - Disable "Dynamic name" test in test_window-named-properties.html for too many intermittent failures --HG-- extra : rebase_source : ea9509b2772c4df1cfe4f2187f7316faf16b3dcb --- .../the-window-object/test_window-named-properties.html.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json index 8626f56fb02a..1d01163cc3c6 100644 --- a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json +++ b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json @@ -1,4 +1,5 @@ { "Static name on the prototype": true, - "constructor": true + "constructor": true, + "Dynamic name": true } From 923fe2cfc2372ba79e0f29276250d81e5695286c Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 14:11:07 +0100 Subject: [PATCH 22/43] Bug 874429 - Disable test_form_autocomplete.html for too many intermittent failures --HG-- extra : rebase_source : 71a634c0f111b981bcbef72092ab430cbe5b5c7d --- toolkit/components/satchel/test/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toolkit/components/satchel/test/Makefile.in b/toolkit/components/satchel/test/Makefile.in index 9d72b1ee2744..f45b5234e429 100644 --- a/toolkit/components/satchel/test/Makefile.in +++ b/toolkit/components/satchel/test/Makefile.in @@ -2,10 +2,12 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# Test disabled for too many intermittent failures (bug 874429) +# test_form_autocomplete.html \ + MOCHITEST_FILES = \ test_bug_511615.html \ test_bug_787624.html \ - test_form_autocomplete.html \ test_form_autocomplete_with_list.html \ test_form_submission.html \ test_form_submission_cap.html \ From 5a8c8a92aed39bae7a877993015fd4590905379e Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 14:25:23 +0100 Subject: [PATCH 23/43] Bug 886781 - Disable test_movement_by_characters.html on Windows 8 for too many intermittent failures --HG-- extra : rebase_source : 608a5680e1e7bcd9ab87b732b0366512abbc1529 --- layout/generic/test/test_movement_by_characters.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layout/generic/test/test_movement_by_characters.html b/layout/generic/test/test_movement_by_characters.html index d2732885ce5f..0447b34a6146 100644 --- a/layout/generic/test/test_movement_by_characters.html +++ b/layout/generic/test/test_movement_by_characters.html @@ -16,6 +16,12 @@ SimpleTest.waitForExplicitFinish(); +if (navigator.userAgent.indexOf("Windows NT 6.2") >= 0) { + todo(false, "Too many intermittent failures on Windows 8 (bug 886781)"); + SimpleTest.finish(); + return; +} + setTimeout(focusing, 0); function focusing() { From 848a0b40dec4236d874c6ea55d8bd5ea782c539f Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 14:52:34 +0100 Subject: [PATCH 24/43] Bug 895390 - Disable browser_privatebrowsing_cache.js for too many intermittent failures --- browser/components/privatebrowsing/test/browser/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/components/privatebrowsing/test/browser/Makefile.in b/browser/components/privatebrowsing/test/browser/Makefile.in index 871ab7498fb3..06cbda67d8c2 100644 --- a/browser/components/privatebrowsing/test/browser/Makefile.in +++ b/browser/components/privatebrowsing/test/browser/Makefile.in @@ -2,11 +2,13 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# Disabled for too many intermittent failures (bug 895390) +# browser_privatebrowsing_cache.js \ + MOCHITEST_BROWSER_FILES = \ head.js \ browser_privatebrowsing_aboutHomeButtonAfterWindowClose.js \ browser_privatebrowsing_aboutSessionRestore.js \ - browser_privatebrowsing_cache.js \ browser_privatebrowsing_certexceptionsui.js \ browser_privatebrowsing_concurrent.js \ browser_privatebrowsing_concurrent_page.html \ From 81c7afbe23a96796bbc1fbbeaa61efbbdf109cd0 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 14:54:10 +0100 Subject: [PATCH 25/43] Bug 897108 - Disable test_playback_rate_playpause.html for too many intermittent failures --- content/media/test/Makefile.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index 3521fe1f6490..c9cab95a78d4 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -25,6 +25,10 @@ # make the test first check canPlayType for the type, and if it's not # supported, just do ok(true, "Type not supported") and stop the test. + +# Disabled for too many intermittent failures (bug 897108) +# test_playback_rate_playpause.html \ + MOCHITEST_FILES = \ allowed.sjs \ can_play_type_ogg.js \ @@ -141,7 +145,6 @@ MOCHITEST_FILES = \ test_VideoPlaybackQuality.html \ test_VideoPlaybackQuality_disabled.html \ test_webvtt_disabled.html \ - test_playback_rate_playpause.html \ test_bug895305.html \ $(NULL) From 41019e510061d4063062251553abcd4a0b9ea05a Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 15:05:11 +0100 Subject: [PATCH 26/43] Bug 901102 - Disable test_streams_element_capture_reset.html on B2G for too many intermittent failures --- testing/mochitest/b2g.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/mochitest/b2g.json b/testing/mochitest/b2g.json index 92fc3f651ead..29aba72ff4f0 100644 --- a/testing/mochitest/b2g.json +++ b/testing/mochitest/b2g.json @@ -14,7 +14,6 @@ "layout/base/tests/test_bug465448.xul":"", "layout/forms/test/test_bug478219.xhtml":"window.closed not working, bug 907795", - "content/media/test":"bug 918299", "content/media/test/test_bug448534.html": "Timed out, bug 894922? Bug 902677 is for the timing out of a lot of media tests", "content/media/mediasource/test/test_MediaSource.html": " ReferenceError: MediaSource is not defined", @@ -58,6 +57,7 @@ "content/media/test/test_source.html": "", "content/media/test/test_source_media.html": "", "content/media/test/test_streams_element_capture.html": "bug 900172 - timeouts", + "content/media/test/test_streams_element_capture_reset.html": "bug 901102", "content/media/test/test_streams_gc.html": "Value being assigned to HTMLMediaElement.currentTime is not a finite floating-point value", "content/media/test/test_unseekable.html":"", "content/media/webaudio":"bug 916135", From 6c34d872101289d3a25a3bd40fbea631dc03ac74 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 15:09:59 +0100 Subject: [PATCH 27/43] Bug 907899 - Mark 759036-1.html as random-if on Android 2.2 for too many intermittent failures --- layout/reftests/bugs/reftest.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 415f04bda19c..0daf33a22fe4 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1715,7 +1715,7 @@ skip-if(B2G) == 751012-1a.html 751012-1-ref.html skip-if(B2G) == 751012-1b.html 751012-1-ref.html random-if(Android) == 753329-1.html about:blank == 758561-1.html 758561-1-ref.html -fuzzy-if(true,1,19) fails-if(d2d) == 759036-1.html 759036-1-ref.html +fuzzy-if(true,1,19) fails-if(d2d) random-if(Android&&AndroidVersion<15) == 759036-1.html 759036-1-ref.html fuzzy-if(true,17,5860) == 759036-2.html 759036-2-ref.html == 776265-1a.html 776265-1-ref.html == 776265-1b.html 776265-1-ref.html From 47e7d03693bd45ace5b8b777ba493459fc3febd8 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 15:11:03 +0100 Subject: [PATCH 28/43] Bug 907903 - Mark 759036-2.html as random-if on Android 2.2 for too many intermittent failures --- layout/reftests/bugs/reftest.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 0daf33a22fe4..fb011c824386 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1716,7 +1716,7 @@ skip-if(B2G) == 751012-1b.html 751012-1-ref.html random-if(Android) == 753329-1.html about:blank == 758561-1.html 758561-1-ref.html fuzzy-if(true,1,19) fails-if(d2d) random-if(Android&&AndroidVersion<15) == 759036-1.html 759036-1-ref.html -fuzzy-if(true,17,5860) == 759036-2.html 759036-2-ref.html +fuzzy-if(true,17,5860) random-if(Android&&AndroidVersion<15) == 759036-2.html 759036-2-ref.html == 776265-1a.html 776265-1-ref.html == 776265-1b.html 776265-1-ref.html == 776265-1c.html 776265-1-ref.html From 003a2a1a4cfc1cd753d76d2b43f112ce474bf488 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 15:15:32 +0100 Subject: [PATCH 29/43] Bug 915350 - Disable testBookmarklets, testHistory, testTabHistory & testBookmarkKeyword for too many intermittent failures --- mobile/android/base/tests/robocop.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index 17eca25bbcd9..f28c10e01afd 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -1,8 +1,8 @@ [testAwesomebar] # [testAwesomebarSwipes] # disabled on fig - bug 880060 # [testBookmark] # disabled on fig - bug 880060 -[testBookmarklets] -[testBookmarkKeyword] +# [testBookmarklets] # see bug 915350 +# [testBookmarkKeyword] # see bug 915350 [testBrowserSearchVisibility] [testJNI] # [testLoad] # see bug 851861 @@ -26,10 +26,10 @@ [testSharedPreferences] # [testThumbnails] # see bug 813107 [testAddonManager] -[testHistory] +# [testHistory] # see bug 915350 # [testVkbOverlap] # see bug 907274 [testDoorHanger] -[testTabHistory] +# [testTabHistory] # see bug 915350 [testShareLink] [testClearPrivateData] [testSettingsMenuItems] From afd145e2e93d93ea48ebf28560f714b49fb3abd3 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 15:30:09 +0100 Subject: [PATCH 30/43] Bug 546169 - Disable browser_bug415846.js for too many intermittent failures --- .../safebrowsing/content/test/Makefile.in | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/browser/components/safebrowsing/content/test/Makefile.in b/browser/components/safebrowsing/content/test/Makefile.in index dc9f7374f0d7..f22343856262 100644 --- a/browser/components/safebrowsing/content/test/Makefile.in +++ b/browser/components/safebrowsing/content/test/Makefile.in @@ -8,10 +8,13 @@ MOCHITEST_BROWSER_FILES := \ browser_bug400731.js \ $(NULL) -# The browser chrome test for bug 415846 doesn't run on Mac because of its -# bizarre special-and-unique snowflake of a help menu. -ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -MOCHITEST_BROWSER_FILES += \ - browser_bug415846.js \ - $(NULL) -endif + +# browser_bug415846.js disabled for too many intermittent failures (bug 546169) +# +# # The browser chrome test for bug 415846 doesn't run on Mac because of its +# # bizarre special-and-unique snowflake of a help menu. +# ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) +# MOCHITEST_BROWSER_FILES += \ +# browser_bug415846.js \ +# $(NULL) +# endif From 8c34623ed15eb69827e28a7ece4372635fe082c4 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 19 Sep 2013 10:34:45 -0400 Subject: [PATCH 31/43] Bug 918321 - Remove some dead code from the JS engine; r=luke --- js/src/builtin/TypedObject.cpp | 6 -- js/src/frontend/BytecodeEmitter.cpp | 2 - js/src/jit/AsmJS.cpp | 20 ------ js/src/jit/IonAnalysis.cpp | 13 ---- js/src/jit/IonFrames.cpp | 4 ++ js/src/jit/MIR.cpp | 8 --- js/src/jit/MIR.h | 3 +- js/src/jscrashreport.cpp | 4 +- js/src/jsinfer.cpp | 95 ----------------------------- js/src/jsscript.cpp | 1 - js/src/vm/Debugger.cpp | 7 --- js/src/vm/Interpreter.cpp | 11 ---- js/src/vm/TypedArrayObject.cpp | 6 -- 13 files changed, 7 insertions(+), 173 deletions(-) diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 9bbe116146aa..8b6850e3b570 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -239,12 +239,6 @@ IsBinaryArray(JSContext *cx, HandleObject obj) return IsBlockOfKind(cx, obj, TypeRepresentation::Array); } -static inline bool -IsBinaryStruct(JSContext *cx, HandleObject obj) -{ - return IsBlockOfKind(cx, obj, TypeRepresentation::Struct); -} - const Class js::DataClass = { "Data", JSCLASS_HAS_CACHED_PROTO(JSProto_Data), diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index d4c926c2ba78..8ee8f0df8aa9 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -605,8 +605,6 @@ EmitNonLocalJumpFixup(ExclusiveContext *cx, BytecodeEmitter *bce, StmtInfoBCE *t #undef FLUSH_POPS } -static const jsatomid INVALID_ATOMID = -1; - static ptrdiff_t EmitGoto(ExclusiveContext *cx, BytecodeEmitter *bce, StmtInfoBCE *toStmt, ptrdiff_t *lastp, SrcNoteType noteType = SRC_NULL) diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index 07582bb43a21..384c299baaca 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -164,13 +164,6 @@ CaseBody(ParseNode *pn) return BinaryRight(pn); } -static inline JSAtom * -StringAtom(ParseNode *pn) -{ - JS_ASSERT(pn->isKind(PNK_STRING)); - return pn->pn_atom; -} - static inline bool IsExpressionStatement(ParseNode *pn) { @@ -285,19 +278,6 @@ FunctionStatementList(ParseNode *fn) return last; } -static inline ParseNode * -FunctionLastReturnStatementOrNull(ParseNode *fn) -{ - ParseNode *listIter = ListHead(FunctionStatementList(fn)); - ParseNode *lastReturn = NULL; - while (listIter) { - if (listIter->isKind(PNK_RETURN)) - lastReturn = listIter; - listIter = listIter->pn_next; - } - return lastReturn; -} - static inline bool IsNormalObjectField(ExclusiveContext *cx, ParseNode *pn) { diff --git a/js/src/jit/IonAnalysis.cpp b/js/src/jit/IonAnalysis.cpp index d3f27c387a7f..13790c4ffd65 100644 --- a/js/src/jit/IonAnalysis.cpp +++ b/js/src/jit/IonAnalysis.cpp @@ -1180,19 +1180,6 @@ jit::BuildPhiReverseMapping(MIRGraph &graph) return true; } -static inline MBasicBlock * -SkipContainedLoop(MBasicBlock *block, MBasicBlock *header) -{ - while (block->loopHeader() || block->isLoopHeader()) { - if (block->loopHeader()) - block = block->loopHeader(); - if (block == header) - break; - block = block->loopPredecessor(); - } - return block; -} - #ifdef DEBUG static bool CheckSuccessorImpliesPredecessor(MBasicBlock *A, MBasicBlock *B) diff --git a/js/src/jit/IonFrames.cpp b/js/src/jit/IonFrames.cpp index 293cd9217d65..145b64b574b6 100644 --- a/js/src/jit/IonFrames.cpp +++ b/js/src/jit/IonFrames.cpp @@ -695,6 +695,7 @@ MarkCalleeToken(JSTracer *trc, CalleeToken token) } } +#ifdef JS_NUNBOX32 static inline uintptr_t ReadAllocation(const IonFrameIterator &frame, const LAllocation *a) { @@ -710,6 +711,7 @@ ReadAllocation(const IonFrameIterator &frame, const LAllocation *a) uint8_t *argv = reinterpret_cast(frame.jsFrame()->argv()); return *reinterpret_cast(argv + index); } +#endif static void MarkActualArguments(JSTracer *trc, const IonFrameIterator &frame) @@ -725,6 +727,7 @@ MarkActualArguments(JSTracer *trc, const IonFrameIterator &frame) gc::MarkValueRoot(trc, &argv[i], "ion-argv"); } +#ifdef JS_NUNBOX32 static inline void WriteAllocation(const IonFrameIterator &frame, const LAllocation *a, uintptr_t value) { @@ -742,6 +745,7 @@ WriteAllocation(const IonFrameIterator &frame, const LAllocation *a, uintptr_t v uint8_t *argv = reinterpret_cast(frame.jsFrame()->argv()); *reinterpret_cast(argv + index) = value; } +#endif static void MarkIonJSFrame(JSTracer *trc, const IonFrameIterator &frame) diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 9f47d19002e1..42b0a846b063 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -1328,14 +1328,6 @@ MMod::canBePowerOfTwoDivisor() const return true; } -static inline MDefinition * -TryFold(MDefinition *original, MDefinition *replacement) -{ - if (original->type() == replacement->type()) - return replacement; - return original; -} - MDefinition * MMod::foldsTo(bool useValueNumbers) { diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index d5c1deeb82fc..1d8cb452da01 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -8455,7 +8455,7 @@ class MAsmJSStoreHeap : public MBinaryInstruction, public MAsmJSHeapAccess class MAsmJSLoadGlobalVar : public MNullaryInstruction { MAsmJSLoadGlobalVar(MIRType type, unsigned globalDataOffset, bool isConstant) - : globalDataOffset_(globalDataOffset), isConstant_(isConstant) + : globalDataOffset_(globalDataOffset) { JS_ASSERT(type == MIRType_Int32 || type == MIRType_Double); setResultType(type); @@ -8463,7 +8463,6 @@ class MAsmJSLoadGlobalVar : public MNullaryInstruction } unsigned globalDataOffset_; - bool isConstant_; public: INSTRUCTION_HEADER(AsmJSLoadGlobalVar); diff --git a/js/src/jscrashreport.cpp b/js/src/jscrashreport.cpp index f5b9c2cd2037..a2fff123e0fb 100644 --- a/js/src/jscrashreport.cpp +++ b/js/src/jscrashreport.cpp @@ -15,10 +15,10 @@ using namespace js; using namespace js::crash; -static const int stack_snapshot_max_size = 32768; - #if defined(XP_WIN) +static const int stack_snapshot_max_size = 32768; + #include static bool diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 08b3299c9be1..10ab2d506f06 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -52,11 +52,6 @@ id_prototype(JSContext *cx) { return NameToId(cx->names().classPrototype); } -static inline jsid -id_length(JSContext *cx) { - return NameToId(cx->names().length); -} - static inline jsid id___proto__(JSContext *cx) { return NameToId(cx->names().proto); @@ -2737,24 +2732,6 @@ TypeObject::print() // Type Analysis ///////////////////////////////////////////////////////////////////// -static inline TypeObject * -GetInitializerType(JSContext *cx, JSScript *script, jsbytecode *pc) -{ - if (!script->compileAndGo) - return NULL; - - JSOp op = JSOp(*pc); - JS_ASSERT(op == JSOP_NEWARRAY || op == JSOP_NEWOBJECT || op == JSOP_NEWINIT); - - bool isArray = (op == JSOP_NEWARRAY || (op == JSOP_NEWINIT && GET_UINT8(pc) == JSProto_Array)); - JSProtoKey key = isArray ? JSProto_Array : JSProto_Object; - - if (UseNewTypeForInitializer(cx, script, pc, key)) - return NULL; - - return TypeScript::InitObject(cx, script, pc, key); -} - /* * Persistent constraint clearing out newScript and definite properties from * an object should a property on another object get a getter or setter. @@ -3200,78 +3177,6 @@ types::UseNewTypeForClone(JSFunction *fun) // TypeScript ///////////////////////////////////////////////////////////////////// -/* - * Returns true if we don't expect to compute the correct types for some value - * pushed by the specified bytecode. - */ -static inline bool -IgnorePushed(const jsbytecode *pc, unsigned index) -{ - switch (JSOp(*pc)) { - /* We keep track of the scopes pushed by BINDNAME separately. */ - case JSOP_BINDNAME: - case JSOP_BINDGNAME: - case JSOP_BINDINTRINSIC: - return true; - - /* Stack not consistent in TRY_BRANCH_AFTER_COND. */ - case JSOP_IN: - case JSOP_EQ: - case JSOP_NE: - case JSOP_LT: - case JSOP_LE: - case JSOP_GT: - case JSOP_GE: - return (index == 0); - - /* Value not determining result is not pushed by OR/AND. */ - case JSOP_OR: - case JSOP_AND: - return (index == 0); - - /* Holes tracked separately. */ - case JSOP_HOLE: - return (index == 0); - - /* Storage for 'with' and 'let' blocks not monitored. */ - case JSOP_ENTERWITH: - case JSOP_ENTERBLOCK: - case JSOP_ENTERLET0: - case JSOP_ENTERLET1: - return true; - - /* We don't keep track of the iteration state for 'for in' or 'for each in' loops. */ - case JSOP_ITER: - case JSOP_ITERNEXT: - case JSOP_MOREITER: - case JSOP_ENDITER: - return true; - - /* Ops which can manipulate values pushed by opcodes we don't model. */ - case JSOP_DUP: - case JSOP_DUP2: - case JSOP_SWAP: - case JSOP_PICK: - return true; - - /* We don't keep track of state indicating whether there is a pending exception. */ - case JSOP_FINALLY: - return true; - - /* - * We don't treat GETLOCAL immediately followed by a pop as a use-before-def, - * and while the type will have been inferred correctly the method JIT - * may not have written the local's initial undefined value to the stack, - * leaving a stale value. - */ - case JSOP_GETLOCAL: - return JSOp(pc[JSOP_GETLOCAL_LENGTH]) == JSOP_POP; - - default: - return false; - } -} - bool JSScript::makeTypes(JSContext *cx) { diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 32765aee5aab..003781c490da 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -1963,7 +1963,6 @@ JSScript::finalize(FreeOp *fop) } static const uint32_t GSN_CACHE_THRESHOLD = 100; -static const uint32_t GSN_CACHE_MAP_INIT_SIZE = 20; void GSNCache::purge() diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index f69d1fb2f160..feca2e206608 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -2718,13 +2718,6 @@ GetScriptReferent(JSObject *obj) return static_cast(obj->getPrivate()); } -static inline void -SetScriptReferent(JSObject *obj, JSScript *script) -{ - JS_ASSERT(obj->getClass() == &DebuggerScript_class); - obj->setPrivateGCThing(script); -} - static void DebuggerScript_trace(JSTracer *trc, JSObject *obj) { diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 0f0a30e93a77..8e48a8934da4 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -60,17 +60,6 @@ using namespace js::types; using mozilla::DebugOnly; using mozilla::PodCopy; -/* Some objects (e.g., With) delegate 'this' to another object. */ -static inline JSObject * -CallThisObjectHook(JSContext *cx, HandleObject obj, Value *argv) -{ - JSObject *thisp = JSObject::thisObject(cx, obj); - if (!thisp) - return NULL; - argv[-1].setObject(*thisp); - return thisp; -} - /* * Note: when Clang 3.2 (32-bit) inlines the two functions below in Interpret, * the conservative stack scanner leaks a ton of memory and this negatively diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index c34a5bf4245e..96539734c959 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -1302,11 +1302,6 @@ template<> inline const int TypeIDOfType() { return ScalarTypeRepresentat template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_FLOAT64; } template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_UINT8_CLAMPED; } -template static inline const bool ElementTypeMayBeDouble() { return false; } -template<> inline const bool ElementTypeMayBeDouble() { return true; } -template<> inline const bool ElementTypeMayBeDouble() { return true; } -template<> inline const bool ElementTypeMayBeDouble() { return true; } - template static inline JSObject * NewArray(JSContext *cx, uint32_t nelements); @@ -1334,7 +1329,6 @@ class TypedArrayObjectTemplate : public TypedArrayObject static const int ArrayTypeID() { return TypeIDOfType(); } static const bool ArrayTypeIsUnsigned() { return TypeIsUnsigned(); } static const bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint(); } - static const bool ArrayElementTypeMayBeDouble() { return ElementTypeMayBeDouble(); } static const size_t BYTES_PER_ELEMENT = sizeof(ThisType); From 57bf6680776cbb8aeb333ccc55221d45970d11eb Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 19 Sep 2013 08:00:01 -0700 Subject: [PATCH 32/43] Bug 915846 - IonMonkey: Various tidy-ups. r=nbp --- js/src/jit/CodeGenerator.cpp | 1 + js/src/jit/LIR-Common.h | 3 ++- js/src/jit/Lowering.cpp | 2 +- js/src/jit/MIR.cpp | 7 ++--- js/src/jit/PerfSpewer.cpp | 1 - js/src/jit/RangeAnalysis.cpp | 34 +++++++++++------------ js/src/jit/RangeAnalysis.h | 52 +++++++++++++++--------------------- 7 files changed, 44 insertions(+), 56 deletions(-) diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index f8973892bbe0..d494b655979c 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -26,6 +26,7 @@ #include "jit/ParallelFunctions.h" #include "jit/ParallelSafetyAnalysis.h" #include "jit/PerfSpewer.h" +#include "jit/RangeAnalysis.h" #include "vm/ForkJoin.h" #include "jsboolinlines.h" diff --git a/js/src/jit/LIR-Common.h b/js/src/jit/LIR-Common.h index f12406016a03..06e1a4a57610 100644 --- a/js/src/jit/LIR-Common.h +++ b/js/src/jit/LIR-Common.h @@ -7,7 +7,6 @@ #ifndef jit_LIR_Common_h #define jit_LIR_Common_h -#include "jit/RangeAnalysis.h" #include "jit/shared/Assembler-shared.h" // This file declares LIR instructions that are common to every platform. @@ -15,6 +14,8 @@ namespace js { namespace jit { +class Range; + template class LBinaryMath : public LInstructionHelper<1, 2 + ExtraUses, Temps> { diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index 6cd32a9950bf..9b38efd70e46 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -2663,7 +2663,7 @@ LIRGenerator::visitAssertRange(MAssertRange *ins) switch (input->type()) { case MIRType_Int32: - lir = new LAssertRangeI(useRegisterAtStart(input)); + lir = new LAssertRangeI(useRegisterAtStart(input)); break; case MIRType_Double: diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 42b0a846b063..b6d46e50cb5e 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -2382,15 +2382,12 @@ MBoundsCheckLower::fallible() void MBeta::printOpcode(FILE *fp) const { - PrintOpcodeName(fp, op()); - fprintf(fp, " "); - getOperand(0)->printName(fp); - fprintf(fp, " "); + MDefinition::printOpcode(fp); Sprinter sp(GetIonContext()->cx); sp.init(); comparison_->print(sp); - fprintf(fp, "%s", sp.string()); + fprintf(fp, " %s", sp.string()); } bool diff --git a/js/src/jit/PerfSpewer.cpp b/js/src/jit/PerfSpewer.cpp index 45ec1653ddb1..cbc29bf2ce0f 100644 --- a/js/src/jit/PerfSpewer.cpp +++ b/js/src/jit/PerfSpewer.cpp @@ -15,7 +15,6 @@ #include "jit/LIR.h" #include "jit/MIR.h" #include "jit/MIRGraph.h" -#include "jit/RangeAnalysis.h" // perf expects its data to be in a file /tmp/perf-PID.map, but for Android // and B2G the map files are written to /data/local/tmp/perf-PID.map diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index 5b7648106be2..0ba6919964c5 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -269,11 +269,11 @@ Range::print(Sprinter &sp) const JS_ASSERT_IF(lower_infinite_, lower_ == JSVAL_INT_MIN); JS_ASSERT_IF(upper_infinite_, upper_ == JSVAL_INT_MAX); - // Real or Natural subset. + // Floating-point or Integer subset. if (canHaveFractionalPart_) - sp.printf("R"); + sp.printf("F"); else - sp.printf("N"); + sp.printf("I"); sp.printf("["); @@ -352,21 +352,21 @@ Range::intersect(const Range *lhs, const Range *rhs, bool *emptyRange) void Range::unionWith(const Range *other) { - bool canHaveFractionalPart = canHaveFractionalPart_ | other->canHaveFractionalPart_; - uint16_t max_exponent = Max(max_exponent_, other->max_exponent_); + bool canHaveFractionalPart = canHaveFractionalPart_ | other->canHaveFractionalPart_; + uint16_t max_exponent = Max(max_exponent_, other->max_exponent_); - if (lower_infinite_ || other->lower_infinite_) - makeLowerInfinite(); - else - setLowerInit(Min(lower_, other->lower_)); + if (lower_infinite_ || other->lower_infinite_) + makeLowerInfinite(); + else + setLowerInit(Min(lower_, other->lower_)); - if (upper_infinite_ || other->upper_infinite_) - makeUpperInfinite(); - else - setUpperInit(Max(upper_, other->upper_)); + if (upper_infinite_ || other->upper_infinite_) + makeUpperInfinite(); + else + setUpperInit(Max(upper_, other->upper_)); - canHaveFractionalPart_ = canHaveFractionalPart; - max_exponent_ = max_exponent; + canHaveFractionalPart_ = canHaveFractionalPart; + max_exponent_ = max_exponent; } static const int64_t RANGE_INF_MAX = int64_t(JSVAL_INT_MAX) + 1; @@ -824,10 +824,8 @@ MConstant::computeRange() int exp = Range::MaxDoubleExponent; // NaN is estimated as a Double which covers everything. - if (IsNaN(d)) { - setRange(new Range(RANGE_INF_MIN, RANGE_INF_MAX, true, exp)); + if (IsNaN(d)) return; - } // Infinity is used to set both lower and upper to the range boundaries. if (IsInfinite(d)) { diff --git a/js/src/jit/RangeAnalysis.h b/js/src/jit/RangeAnalysis.h index 196f770541d3..a8b13b896bca 100644 --- a/js/src/jit/RangeAnalysis.h +++ b/js/src/jit/RangeAnalysis.h @@ -204,9 +204,6 @@ class Range : public TempObject { void print(Sprinter &sp) const; bool update(const Range *other); - bool update(const Range &other) { - return update(&other); - } // Unlike the other operations, unionWith is an in-place // modification. This is to avoid a bunch of useless extra @@ -233,67 +230,62 @@ class Range : public TempObject { static bool negativeZeroMul(const Range *lhs, const Range *rhs); - inline void makeLowerInfinite() { + void makeLowerInfinite() { lower_infinite_ = true; lower_ = JSVAL_INT_MIN; if (max_exponent_ < MaxInt32Exponent) max_exponent_ = MaxInt32Exponent; } - inline void makeUpperInfinite() { + void makeUpperInfinite() { upper_infinite_ = true; upper_ = JSVAL_INT_MAX; if (max_exponent_ < MaxInt32Exponent) max_exponent_ = MaxInt32Exponent; } - inline void makeRangeInfinite() { - makeLowerInfinite(); - makeUpperInfinite(); - max_exponent_ = MaxDoubleExponent; - } - inline bool isLowerInfinite() const { + bool isLowerInfinite() const { return lower_infinite_; } - inline bool isUpperInfinite() const { + bool isUpperInfinite() const { return upper_infinite_; } - inline bool isInt32() const { + bool isInt32() const { return !isLowerInfinite() && !isUpperInfinite(); } - inline bool isBoolean() const { + bool isBoolean() const { return lower() >= 0 && upper() <= 1; } - inline bool hasRoundingErrors() const { + bool hasRoundingErrors() const { return canHaveFractionalPart() || exponent() >= MaxTruncatableExponent; } - inline bool isInfinite() const { + bool isInfinite() const { return exponent() >= MaxDoubleExponent; } - inline bool canHaveFractionalPart() const { + bool canHaveFractionalPart() const { return canHaveFractionalPart_; } - inline uint16_t exponent() const { + uint16_t exponent() const { return max_exponent_; } - inline uint16_t numBits() const { + uint16_t numBits() const { return max_exponent_ + 1; // 2^0 -> 1 } - inline int32_t lower() const { + int32_t lower() const { return lower_; } - inline int32_t upper() const { + int32_t upper() const { return upper_; } - inline void setLowerInit(int64_t x) { + void setLowerInit(int64_t x) { if (x > JSVAL_INT_MAX) { // c.c lower_ = JSVAL_INT_MAX; lower_infinite_ = false; @@ -304,12 +296,12 @@ class Range : public TempObject { lower_infinite_ = false; } } - inline void setLower(int64_t x) { + void setLower(int64_t x) { setLowerInit(x); rectifyExponent(); JS_ASSERT_IF(lower_infinite_, lower_ == JSVAL_INT_MIN); } - inline void setUpperInit(int64_t x) { + void setUpperInit(int64_t x) { if (x > JSVAL_INT_MAX) { makeUpperInfinite(); } else if (x < JSVAL_INT_MIN) { // c.c @@ -320,20 +312,20 @@ class Range : public TempObject { upper_infinite_ = false; } } - inline void setUpper(int64_t x) { + void setUpper(int64_t x) { setUpperInit(x); rectifyExponent(); JS_ASSERT_IF(upper_infinite_, upper_ == JSVAL_INT_MAX); } - inline void setInt32() { + void setInt32() { lower_infinite_ = false; upper_infinite_ = false; canHaveFractionalPart_ = false; max_exponent_ = MaxInt32Exponent; } - inline void set(int64_t l, int64_t h, bool f = false, uint16_t e = MaxInt32Exponent) { + void set(int64_t l, int64_t h, bool f = false, uint16_t e = MaxInt32Exponent) { max_exponent_ = e; setLowerInit(l); setUpperInit(h); @@ -374,7 +366,7 @@ class Range : public TempObject { // Note: // exponent of JSVAL_INT_MIN == 32 // exponent of JSVAL_INT_MAX == 31 - inline void rectifyExponent() { + void rectifyExponent() { if (!isInt32()) { JS_ASSERT(max_exponent_ >= MaxInt32Exponent); return; @@ -394,10 +386,10 @@ class Range : public TempObject { return symbolicUpper_; } - inline void setSymbolicLower(SymbolicBound *bound) { + void setSymbolicLower(SymbolicBound *bound) { symbolicLower_ = bound; } - inline void setSymbolicUpper(SymbolicBound *bound) { + void setSymbolicUpper(SymbolicBound *bound) { symbolicUpper_ = bound; } }; From 629685141bbd9a123832982a34ab6d159f3cdd87 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 19 Sep 2013 08:03:22 -0700 Subject: [PATCH 33/43] Bug 915846 - IonMonkey: Fix MBoundsCheckLower elimination. r=nbp --- js/src/jit/MIR.cpp | 6 ------ js/src/jit/MIR.h | 8 ++++++-- js/src/jit/RangeAnalysis.cpp | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index b6d46e50cb5e..132cd32cf030 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -2373,12 +2373,6 @@ MNot::foldsTo(bool useValueNumbers) return this; } -bool -MBoundsCheckLower::fallible() -{ - return !range() || range()->lower() < minimum_; -} - void MBeta::printOpcode(FILE *fp) const { diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 1d8cb452da01..1c68cb08dbd0 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -4974,9 +4974,10 @@ class MBoundsCheckLower : public MUnaryInstruction { int32_t minimum_; + bool fallible_; MBoundsCheckLower(MDefinition *index) - : MUnaryInstruction(index), minimum_(0) + : MUnaryInstruction(index), minimum_(0), fallible_(true) { setGuard(); setMovable(); @@ -5002,7 +5003,10 @@ class MBoundsCheckLower AliasSet getAliasSet() const { return AliasSet::None(); } - bool fallible(); + bool fallible() const { + return fallible_; + } + void collectRangeInfo(); }; // Load a value from a dense array's element vector and does a hole check if the diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index 0ba6919964c5..d9be15db9b62 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -1538,6 +1538,7 @@ ConvertLinearSum(MBasicBlock *block, const LinearSum &sum) def = MAdd::New(def, term.term); def->toAdd()->setInt32(); block->insertBefore(block->lastIns(), def->toInstruction()); + def->computeRange(); } else { def = term.term; } @@ -1545,10 +1546,12 @@ ConvertLinearSum(MBasicBlock *block, const LinearSum &sum) if (!def) { def = MConstant::New(Int32Value(0)); block->insertBefore(block->lastIns(), def->toInstruction()); + def->computeRange(); } def = MSub::New(def, term.term); def->toSub()->setInt32(); block->insertBefore(block->lastIns(), def->toInstruction()); + def->computeRange(); } else { JS_ASSERT(term.scale != 0); MConstant *factor = MConstant::New(Int32Value(term.scale)); @@ -1556,10 +1559,12 @@ ConvertLinearSum(MBasicBlock *block, const LinearSum &sum) MMul *mul = MMul::New(term.term, factor); mul->setInt32(); block->insertBefore(block->lastIns(), mul); + mul->computeRange(); if (def) { def = MAdd::New(def, mul); def->toAdd()->setInt32(); block->insertBefore(block->lastIns(), def->toInstruction()); + def->computeRange(); } else { def = mul; } @@ -1569,6 +1574,7 @@ ConvertLinearSum(MBasicBlock *block, const LinearSum &sum) if (!def) { def = MConstant::New(Int32Value(0)); block->insertBefore(block->lastIns(), def->toInstruction()); + def->computeRange(); } return def; @@ -1621,8 +1627,6 @@ RangeAnalysis::tryHoistBoundsCheck(MBasicBlock *header, MBoundsCheck *ins) return false; if (!SafeSub(lowerConstant, lower->sum.constant(), &lowerConstant)) return false; - MBoundsCheckLower *lowerCheck = MBoundsCheckLower::New(lowerTerm); - lowerCheck->setMinimum(lowerConstant); // We are checking that index < boundsLength, and know that // index <= upperTerm + upperConstant. Thus, check that: @@ -1632,6 +1636,10 @@ RangeAnalysis::tryHoistBoundsCheck(MBasicBlock *header, MBoundsCheck *ins) int32_t upperConstant = index.constant; if (!SafeAdd(upper->sum.constant(), upperConstant, &upperConstant)) return false; + + MBoundsCheckLower *lowerCheck = MBoundsCheckLower::New(lowerTerm); + lowerCheck->setMinimum(lowerConstant); + MBoundsCheck *upperCheck = MBoundsCheck::New(upperTerm, ins->length()); upperCheck->setMinimum(upperConstant); upperCheck->setMaximum(upperConstant); @@ -2141,3 +2149,9 @@ MMod::collectRangeInfo() { canBeNegativeDividend_ = !lhs()->range() || lhs()->range()->lower() < 0; } + +void +MBoundsCheckLower::collectRangeInfo() +{ + fallible_ = !index()->range() || index()->range()->lower() < minimum_; +} From 0b1076608d32959356d30afeb58701f4c87b7efd Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Thu, 19 Sep 2013 11:27:50 -0400 Subject: [PATCH 34/43] Backed out changeset 98271bb483eb (bug 914607) for crashtest/reftest crashes. CLOSED TREE --- configure.in | 1 + dom/plugins/base/nsNPAPIPlugin.cpp | 4 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 2 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 2 +- .../base/nsPluginStreamListenerPeer.cpp | 2 +- dom/plugins/base/nsPluginsDirUnix.cpp | 4 +- dom/plugins/ipc/PluginInstanceChild.cpp | 2 +- gfx/thebes/gfxFT2FontList.cpp | 2 +- image/decoders/icon/nsIconModule.cpp | 2 +- layout/xul/base/src/nsMenuBarFrame.cpp | 2 +- testing/tools/screenshot/gdk-screenshot.cpp | 4 +- .../jsdownloads/src/DownloadPlatform.cpp | 10 +-- toolkit/xre/nsX11ErrorHandler.cpp | 2 +- widget/gtk2/gtkdrawing.h | 4 +- widget/gtk2/mozcontainer.c | 6 +- widget/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/gtk2/nsWindow.cpp | 72 +++++++++---------- widget/gtk2/nsWindow.h | 6 +- 18 files changed, 66 insertions(+), 65 deletions(-) diff --git a/configure.in b/configure.in index d930e30bf118..81b764200214 100644 --- a/configure.in +++ b/configure.in @@ -4394,6 +4394,7 @@ cairo-gtk2|cairo-gtk2-x11) TK_CFLAGS='$(MOZ_GTK2_CFLAGS)' TK_LIBS='$(MOZ_GTK2_LIBS)' + AC_DEFINE(MOZ_WIDGET_GTK2) MOZ_WIDGET_GTK=2 AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK) MOZ_PDF_PRINTING=1 diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 501f82455215..05dfcd7b7b6a 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -1922,7 +1922,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) return NPERR_NO_ERROR; } } -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 // adobe nppdf calls XtGetApplicationNameAndClass(display, // &instance, &class) we have to init Xt toolkit before get // XtDisplay just call gtk_xtbin_new(w,0) once @@ -1943,7 +1943,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) return NPERR_GENERIC_ERROR; #endif -#if defined(XP_WIN) || defined(XP_OS2) || (MOZ_WIDGET_GTK == 2) \ +#if defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_WIDGET_GTK2) \ || defined(MOZ_WIDGET_QT) case NPNVnetscapeWindow: { if (!npp || !npp->ndata) diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 1259ce45ccc2..492c77495671 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -557,7 +557,7 @@ nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window) if (!window || RUNNING != mRunning) return NS_OK; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) // bug 108347, flash plugin on linux doesn't like window->width <= // 0, but Java needs wants this call. if (!nsPluginHost::IsJavaMIMEType(mMIMEType) && window->type == NPWindowTypeWindow && diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 29b71f7e5e44..93ed1025d4d2 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -75,7 +75,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); #include "nsPluginUtilsOSX.h" #endif -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 #include #include #include diff --git a/dom/plugins/base/nsPluginStreamListenerPeer.cpp b/dom/plugins/base/nsPluginStreamListenerPeer.cpp index f06bce65104c..b1759f47e43c 100644 --- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp +++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp @@ -737,7 +737,7 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request, if (owner) { NPWindow* window = nullptr; owner->GetWindow(window); -#if (MOZ_WIDGET_GTK == 2) || defined(MOZ_WIDGET_QT) +#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT) // Should call GetPluginPort() here. // This part is copied from nsPluginInstanceOwner::GetPluginPort(). nsCOMPtr widget; diff --git a/dom/plugins/base/nsPluginsDirUnix.cpp b/dom/plugins/base/nsPluginsDirUnix.cpp index 3724366f515e..ad1744a97cdd 100644 --- a/dom/plugins/base/nsPluginsDirUnix.cpp +++ b/dom/plugins/base/nsPluginsDirUnix.cpp @@ -39,7 +39,7 @@ #define DEFAULT_X11_PATH "" #endif -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) #define PLUGIN_MAX_LEN_OF_TMP_ARR 512 @@ -265,7 +265,7 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary) libSpec.value.pathname = path.get(); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) // Normally, Mozilla isn't linked against libXt and libXext // since it's a Gtk/Gdk application. On the other hand, diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 83998fee28d0..fb83400e55ea 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -1101,7 +1101,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) CreateWindow(aWindow); } -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 if (mXEmbed && gtk_check_version(2,18,7) != NULL) { // older if (aWindow.type == NPWindowTypeWindow) { GdkWindow* socket_window = gdk_window_lookup(static_cast(aWindow.window)); diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 3453eee9d1a4..258c8bf8fcd7 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -6,7 +6,7 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) #include "gfxPlatformGtk.h" #define gfxToolkitPlatform gfxPlatformGtk #elif defined(MOZ_WIDGET_QT) diff --git a/image/decoders/icon/nsIconModule.cpp b/image/decoders/icon/nsIconModule.cpp index a3de26b6fa21..4cf7c8f0d1d7 100644 --- a/image/decoders/icon/nsIconModule.cpp +++ b/image/decoders/icon/nsIconModule.cpp @@ -38,7 +38,7 @@ static const mozilla::Module::CategoryEntry kIconCategories[] = { static void IconDecoderModuleDtor() { -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 nsIconChannel::Shutdown(); #endif } diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp index 762d32438282..dfad8ccbb4d1 100644 --- a/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/layout/xul/base/src/nsMenuBarFrame.cpp @@ -149,7 +149,7 @@ nsMenuBarFrame::ToggleMenuActiveState() // Activate the menu bar SetActive(true); -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 firstFrame->OpenMenu(true); #else firstFrame->SelectMenu(true); diff --git a/testing/tools/screenshot/gdk-screenshot.cpp b/testing/tools/screenshot/gdk-screenshot.cpp index 0a356aa5daaa..a8d713822fa4 100644 --- a/testing/tools/screenshot/gdk-screenshot.cpp +++ b/testing/tools/screenshot/gdk-screenshot.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) gdk_init(&argc, &argv); // TODO GTK3 -#if defined(HAVE_LIBXSS) && (MOZ_WIDGET_GTK == 2) +#if defined(HAVE_LIBXSS) && defined(MOZ_WIDGET_GTK2) int event_base, error_base; Bool have_xscreensaver = XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base); @@ -129,7 +129,7 @@ int main(int argc, char** argv) GdkWindow* window = gdk_get_default_root_window(); GdkPixbuf* screenshot = NULL; // TODO GTK3 -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) screenshot = gdk_pixbuf_get_from_drawable(NULL, window, NULL, 0, 0, 0, 0, gdk_screen_width(), diff --git a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp index 8fad2458d9b4..a7a2c7eb89c2 100644 --- a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp +++ b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp @@ -25,7 +25,7 @@ #include "AndroidBridge.h" #endif -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 #include #endif @@ -43,7 +43,7 @@ DownloadPlatform* DownloadPlatform::GetDownloadPlatform() NS_ADDREF(gDownloadPlatformService); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) g_type_init(); #endif @@ -67,10 +67,10 @@ static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpoint nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, const nsACString& aContentType, bool aIsPrivate) { -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || (MOZ_WIDGET_GTK == 2) +#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK2) nsAutoString path; if (aTarget && NS_SUCCEEDED(aTarget->GetPath(path))) { -#if defined(XP_WIN) || (MOZ_WIDGET_GTK == 2) +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK2) // On Windows and Gtk, add the download to the system's "recent documents" // list, with a pref to disable. { @@ -78,7 +78,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, if (addToRecentDocs && !aIsPrivate) { #ifdef XP_WIN ::SHAddToRecentDocs(SHARD_PATHW, path.get()); -#elif (MOZ_WIDGET_GTK == 2) +#elif defined(MOZ_WIDGET_GTK2) GtkRecentManager* manager = gtk_recent_manager_get_default(); gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(), diff --git a/toolkit/xre/nsX11ErrorHandler.cpp b/toolkit/xre/nsX11ErrorHandler.cpp index 97245e7b67c3..d3a48ca468cf 100644 --- a/toolkit/xre/nsX11ErrorHandler.cpp +++ b/toolkit/xre/nsX11ErrorHandler.cpp @@ -58,7 +58,7 @@ X11Error(Display *display, XErrorEvent *event) { } XCloseDisplay(tmpDisplay); -#if (MOZ_WIDGET_GTK == 2) +#ifdef MOZ_WIDGET_GTK2 // GDK2 calls XCloseDevice the devices that it opened on startup, but // the XI protocol no longer ensures that the devices will still exist. // If they have been removed, then a BadDevice error results. Ignore diff --git a/widget/gtk2/gtkdrawing.h b/widget/gtk2/gtkdrawing.h index cce2f88e0762..5d38574bd7ca 100644 --- a/widget/gtk2/gtkdrawing.h +++ b/widget/gtk2/gtkdrawing.h @@ -209,7 +209,7 @@ gint moz_gtk_enable_style_props(style_prop_t styleGetProp); */ gint moz_gtk_shutdown(); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) /** * Retrieves the colormap to use for drawables passed to moz_gtk_widget_paint. */ @@ -217,7 +217,7 @@ GdkColormap* moz_gtk_widget_get_colormap(); #endif /*** Widget drawing ***/ -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) /** * Paint a widget in the current theme. * widget: a constant giving the widget to paint diff --git a/widget/gtk2/mozcontainer.c b/widget/gtk2/mozcontainer.c index ded61f678b55..262ea6749c33 100644 --- a/widget/gtk2/mozcontainer.c +++ b/widget/gtk2/mozcontainer.c @@ -236,14 +236,14 @@ moz_container_realize (GtkWidget *widget) attributes.visual = gtk_widget_get_visual (widget); attributes.window_type = GDK_WINDOW_CHILD; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask |= GDK_WA_COLORMAP; #endif window = gdk_window_new (parent, &attributes, attributes_mask); gdk_window_set_user_data (window, widget); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) /* TODO GTK3? */ /* set the back pixmap to None so that you don't end up with the gtk default which is BlackPixel */ @@ -256,7 +256,7 @@ moz_container_realize (GtkWidget *widget) gtk_widget_set_window (widget, window); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) widget->style = gtk_style_attach (widget->style, widget->window); #endif } diff --git a/widget/gtk2/nsNativeThemeGTK.cpp b/widget/gtk2/nsNativeThemeGTK.cpp index 5c4833063342..a22741a97e16 100644 --- a/widget/gtk2/nsNativeThemeGTK.cpp +++ b/widget/gtk2/nsNativeThemeGTK.cpp @@ -630,7 +630,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, return true; } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) class ThemeRenderer : public gfxGdkNativeRenderer { public: ThemeRenderer(GtkWidgetState aState, GtkThemeWidgetType aGTKWidgetType, @@ -822,7 +822,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext, gdk_error_trap_push (); } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) // The gdk_clip is just advisory here, meaning "you don't // need to draw outside this rect if you don't feel like it!" GdkRectangle gdk_clip = {0, 0, drawingRect.width, drawingRect.height}; diff --git a/widget/gtk2/nsWindow.cpp b/widget/gtk2/nsWindow.cpp index 4f844373d601..1e24d7593473 100644 --- a/widget/gtk2/nsWindow.cpp +++ b/widget/gtk2/nsWindow.cpp @@ -44,7 +44,7 @@ #endif #endif /* MOZ_X11 */ #include -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) #include #endif @@ -156,7 +156,7 @@ static int is_parent_grab_leave(GdkEventCrossing *aEvent); static void GetBrandName(nsXPIDLString& brandName); /* callbacks from widgets */ -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) static gboolean expose_event_cb (GtkWidget *widget, GdkEventExpose *event); #else @@ -302,7 +302,7 @@ protected: static inline int32_t GetBitmapStride(int32_t width) { -#if defined(MOZ_X11) || (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_X11) || defined(MOZ_WIDGET_GTK2) return (width+7)/8; #else return cairo_format_stride_for_width(CAIRO_FORMAT_A1, width); @@ -651,7 +651,7 @@ nsWindow::Destroy(void) gFocusWindow = nullptr; } -#if (MOZ_WIDGET_GTK == 2) && defined(MOZ_X11) +#if defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11) // make sure that we remove ourself as the plugin focus window if (gPluginFocusWindow == this) { gPluginFocusWindow->LoseNonXEmbedPluginFocus(); @@ -1907,7 +1907,7 @@ gdk_window_flash(GdkWindow * aGdkWindow, GdkGC * gc = 0; GdkColor white; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gdk_window_get_geometry(aGdkWindow,NULL,NULL,&width,&height,NULL); #else gdk_window_get_geometry(aGdkWindow,NULL,NULL,&width,&height); @@ -1955,7 +1955,7 @@ gdk_window_flash(GdkWindow * aGdkWindow, #endif // DEBUG #endif -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gboolean nsWindow::OnExposeEvent(GdkEventExpose *aEvent) #else @@ -2000,7 +2000,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) return FALSE; } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) GdkRectangle *rects; gint nrects; gdk_region_get_rectangles(aEvent->region, &rects, &nrects); @@ -2020,7 +2020,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) #endif // GTK3 TODO? -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) if (nrects > MAX_RECTS_IN_REGION) { // Just use the bounding box rects[0] = aEvent->area; @@ -2034,7 +2034,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) nsIntRegion region; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) GdkRectangle *r = rects; GdkRectangle *r_end = rects + nrects; #else @@ -2087,7 +2087,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) } if (region.IsEmpty()) { -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) g_free(rects); #else cairo_rectangle_list_destroy(rects); @@ -2112,7 +2112,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) return TRUE; } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) nsRefPtr ctx = new gfxContext(GetThebesSurface()); #else nsRefPtr ctx = new gfxContext(GetThebesSurface(cr)); @@ -2207,7 +2207,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) } # ifdef MOZ_HAVE_SHMIMAGE if (nsShmImage::UseShm() && MOZ_LIKELY(!mIsDestroyed)) { -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) mShmImage->Put(mGdkWindow, rects, r_end); #else mShmImage->Put(mGdkWindow, rects); @@ -2216,7 +2216,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) # endif // MOZ_HAVE_SHMIMAGE #endif // MOZ_X11 -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) g_free(rects); #else cairo_rectangle_list_destroy(rects); @@ -2225,7 +2225,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) listener->DidPaintWindow(); // Synchronously flush any new dirty areas -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) GdkRegion* dirtyArea = gdk_window_get_update_area(mGdkWindow); #else cairo_region_t* dirtyArea = gdk_window_get_update_area(mGdkWindow); @@ -2233,7 +2233,7 @@ nsWindow::OnExposeEvent(cairo_t *cr) if (dirtyArea) { gdk_window_invalidate_region(mGdkWindow, dirtyArea, false); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gdk_region_destroy(dirtyArea); #else cairo_region_destroy(dirtyArea); @@ -2466,7 +2466,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent) synthEvent = true; XNextEvent (GDK_WINDOW_XDISPLAY(aEvent->window), &xevent); } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) // if plugins still keeps the focus, get it back if (gPluginFocusWindow && gPluginFocusWindow != this) { nsRefPtr kungFuDeathGrip = gPluginFocusWindow; @@ -2814,7 +2814,7 @@ nsWindow::OnContainerFocusOutEvent(GdkEventFocus *aEvent) } } -#if (MOZ_WIDGET_GTK == 2) && defined(MOZ_X11) +#if defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11) // plugin lose focus if (gPluginFocusWindow) { nsRefPtr kungFuDeathGrip = gPluginFocusWindow; @@ -3279,7 +3279,7 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget) attributes.visual = gtk_widget_get_visual(widget); attributes.window_type = GDK_WINDOW_CHILD; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) attributes_mask |= GDK_WA_COLORMAP; attributes.colormap = gtk_widget_get_colormap(widget); #endif @@ -3288,7 +3288,7 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget) gdk_window_set_user_data(window, widget); // GTK3 TODO? -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) /* set the default pixmap to None so that you don't end up with the gtk default which is BlackPixel. */ gdk_window_set_back_pixmap(window, NULL, FALSE); @@ -3420,7 +3420,7 @@ nsWindow::Create(nsIWidget *aParent, // are on a compositing window manager. GdkScreen *screen = gtk_widget_get_screen(mShell); if (gdk_screen_is_composited(screen)) { -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen); gtk_widget_set_colormap(mShell, colormap); @@ -3599,7 +3599,7 @@ nsWindow::Create(nsIWidget *aParent, hierarchy_changed_cb(GTK_WIDGET(mContainer), NULL); // Expose, focus, key, and drag events are sent even to GTK_NO_WINDOW // widgets. -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) g_signal_connect(mContainer, "expose_event", G_CALLBACK(expose_event_cb), NULL); #else @@ -3656,7 +3656,7 @@ nsWindow::Create(nsIWidget *aParent, } if (eventWidget) { -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) // Don't let GTK mess with the shapes of our GdkWindows GTK_PRIVATE_SET_FLAG(eventWidget, GTK_HAS_SHAPE_MASK); #endif @@ -4097,7 +4097,7 @@ nsWindow::SetWindowClipRegion(const nsTArray& aRects, if (!mGdkWindow) return; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) GdkRegion *region = gdk_region_new(); // aborts on OOM for (uint32_t i = 0; i < newRects->Length(); ++i) { const nsIntRect& r = newRects->ElementAt(i); @@ -4227,7 +4227,7 @@ nsWindow::ApplyTransparencyBitmap() maskPixmap, ShapeSet); XFreePixmap(xDisplay, maskPixmap); #else -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gtk_widget_reset_shapes(mShell); GdkBitmap* maskBitmap = gdk_bitmap_create_from_data(gtk_widget_get_window(mShell), mTransparencyBitmap, @@ -4496,7 +4496,7 @@ nsWindow::SetNonXEmbedPluginFocus() LOGFOCUS(("\t curFocusWindow=%p\n", curFocusWindow)); GdkWindow* toplevel = gdk_window_get_toplevel(mGdkWindow); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) GdkWindow *gdkfocuswin = gdk_window_lookup(curFocusWindow); #else GdkWindow *gdkfocuswin = gdk_x11_window_lookup_for_display(gdkDisplay, @@ -4779,7 +4779,7 @@ is_mouse_in_window (GdkWindow* aWindow, gdouble aMouseX, gdouble aMouseY) window = gdk_window_get_parent(window); } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gdk_drawable_get_size(aWindow, &w, &h); #else w = gdk_window_get_width(aWindow); @@ -4983,7 +4983,7 @@ get_gtk_cursor(nsCursor aCursor) // gtk callbacks -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) static gboolean expose_event_cb(GtkWidget *widget, GdkEventExpose *event) { @@ -5290,7 +5290,7 @@ plugin_window_filter_func(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) break; xeventWindow = xevent->xreparent.window; } -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) plugin_window = gdk_window_lookup(xeventWindow); #else plugin_window = gdk_x11_window_lookup_for_display( @@ -5301,7 +5301,7 @@ plugin_window_filter_func(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) get_gtk_widget_for_gdk_window(plugin_window); // TODO GTK3 -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) if (GTK_IS_XTBIN(widget)) { nswindow->SetPluginType(nsWindow::PluginType_NONXEMBED); break; @@ -5668,7 +5668,7 @@ get_inner_gdk_window (GdkWindow *aWindow, child = g_list_previous(child)) { GdkWindow *childWindow = (GdkWindow *) child->data; if (get_window_for_gdk_window(childWindow)) { -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gdk_window_get_geometry(childWindow, &cx, &cy, &cw, &ch, NULL); #else gdk_window_get_geometry(childWindow, &cx, &cy, &cw, &ch); @@ -5868,7 +5868,7 @@ nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) return NS_OK; } -#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2) /* static */ already_AddRefed nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, const nsIntSize& aSize) @@ -5910,7 +5910,7 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, } #endif -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) TemporaryRef nsWindow::StartRemoteDrawing() { @@ -5930,7 +5930,7 @@ nsWindow::StartRemoteDrawing() // return the gfxASurface for rendering to this widget gfxASurface* -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) nsWindow::GetThebesSurface() #else nsWindow::GetThebesSurface(cairo_t *cr) @@ -5939,7 +5939,7 @@ nsWindow::GetThebesSurface(cairo_t *cr) if (!mGdkWindow) return nullptr; -#if (MOZ_WIDGET_GTK != 2) +#if !defined(MOZ_WIDGET_GTK2) cairo_surface_t *surf = cairo_get_target(cr); if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { NS_NOTREACHED("Missing cairo target?"); @@ -5950,7 +5950,7 @@ nsWindow::GetThebesSurface(cairo_t *cr) #ifdef MOZ_X11 gint width, height; -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gdk_drawable_get_size(GDK_DRAWABLE(mGdkWindow), &width, &height); #else width = gdk_window_get_width(mGdkWindow); @@ -5980,7 +5980,7 @@ nsWindow::GetThebesSurface(cairo_t *cr) if (!usingShm) # endif // MOZ_HAVE_SHMIMAGE -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) mThebesSurface = new gfxXlibSurface (GDK_WINDOW_XDISPLAY(mGdkWindow), gdk_x11_window_get_xid(mGdkWindow), diff --git a/widget/gtk2/nsWindow.h b/widget/gtk2/nsWindow.h index 0651b9876965..076a8e16d087 100644 --- a/widget/gtk2/nsWindow.h +++ b/widget/gtk2/nsWindow.h @@ -164,7 +164,7 @@ public: gint ConvertBorderStyles(nsBorderStyle aStyle); // event callbacks -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gboolean OnExposeEvent(GdkEventExpose *aEvent); #else gboolean OnExposeEvent(cairo_t *cr); @@ -196,7 +196,7 @@ public: guint aTime, gpointer aData); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) mozilla::TemporaryRef StartRemoteDrawing() MOZ_OVERRIDE; #endif @@ -277,7 +277,7 @@ public: nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect, uint8_t* aAlphas, int32_t aStride); -#if (MOZ_WIDGET_GTK == 2) +#if defined(MOZ_WIDGET_GTK2) gfxASurface *GetThebesSurface(); static already_AddRefed GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, From 7e1838537cfb763760bc4df2a8c47a1bac722e37 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 19 Sep 2013 11:49:04 -0400 Subject: [PATCH 35/43] Bug 886781 follow-up: Disable the test properly, we can't return from the global scope Landed on a CLOSED TREE --- layout/generic/test/test_movement_by_characters.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/layout/generic/test/test_movement_by_characters.html b/layout/generic/test/test_movement_by_characters.html index 0447b34a6146..7573fb4571b3 100644 --- a/layout/generic/test/test_movement_by_characters.html +++ b/layout/generic/test/test_movement_by_characters.html @@ -19,11 +19,10 @@ SimpleTest.waitForExplicitFinish(); if (navigator.userAgent.indexOf("Windows NT 6.2") >= 0) { todo(false, "Too many intermittent failures on Windows 8 (bug 886781)"); SimpleTest.finish(); - return; +} else { + setTimeout(focusing, 0); } -setTimeout(focusing, 0); - function focusing() { document.getElementById("editor").focus(); // This seems to be necessary because the selection is not set up properly otherwise From 9f3f2280c44e451a8cd11d8ef79ecb1aadf483a6 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 17:08:28 +0100 Subject: [PATCH 36/43] Bug 859075 - Disable test_window-named-properties.html via Makefile CLOSED TREE --- .../failures/html/html/browsers/the-window-object/Makefile.in | 4 +++- .../the-window-object/test_window-named-properties.html.json | 3 +-- dom/imptests/html/html/browsers/the-window-object/Makefile.in | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dom/imptests/failures/html/html/browsers/the-window-object/Makefile.in b/dom/imptests/failures/html/html/browsers/the-window-object/Makefile.in index f9295f7b94a6..3b1cddf8eac7 100644 --- a/dom/imptests/failures/html/html/browsers/the-window-object/Makefile.in +++ b/dom/imptests/failures/html/html/browsers/the-window-object/Makefile.in @@ -1,8 +1,10 @@ # THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT +# Disabled due to bug 859075 +# test_window-named-properties.html.json \ + MOCHITEST_FILES := \ test_window-indexed-properties-strict.html.json \ - test_window-named-properties.html.json \ test_window-properties.html.json \ test_window-prototype-chain.html.json \ $(NULL) diff --git a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json index 1d01163cc3c6..8626f56fb02a 100644 --- a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json +++ b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json @@ -1,5 +1,4 @@ { "Static name on the prototype": true, - "constructor": true, - "Dynamic name": true + "constructor": true } diff --git a/dom/imptests/html/html/browsers/the-window-object/Makefile.in b/dom/imptests/html/html/browsers/the-window-object/Makefile.in index 615783814da1..4ce062169909 100644 --- a/dom/imptests/html/html/browsers/the-window-object/Makefile.in +++ b/dom/imptests/html/html/browsers/the-window-object/Makefile.in @@ -1,7 +1,9 @@ # THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT +# Disabled due to bug 859075 +# test_window-indexed-properties.html \ + MOCHITEST_FILES := \ - test_window-indexed-properties.html \ test_window-indexed-properties-strict.html \ test_window-named-properties.html \ test_window-properties.html \ From ee8b74ea2a1e87af2b75d6ee0fd013a6a3df3c26 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 19 Sep 2013 18:18:15 +0100 Subject: [PATCH 37/43] Bug 859075 - Sigh, disable the correct test this time CLOSED TREE --- dom/imptests/html/html/browsers/the-window-object/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dom/imptests/html/html/browsers/the-window-object/Makefile.in b/dom/imptests/html/html/browsers/the-window-object/Makefile.in index 4ce062169909..7d14294c1e66 100644 --- a/dom/imptests/html/html/browsers/the-window-object/Makefile.in +++ b/dom/imptests/html/html/browsers/the-window-object/Makefile.in @@ -1,11 +1,11 @@ # THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT # Disabled due to bug 859075 -# test_window-indexed-properties.html \ +# test_window-named-properties.html \ MOCHITEST_FILES := \ + test_window-indexed-properties.html \ test_window-indexed-properties-strict.html \ - test_window-named-properties.html \ test_window-properties.html \ test_window-prototype-chain.html \ $(NULL) From 95d889911dafa514e697b072533e6473c3b3fe85 Mon Sep 17 00:00:00 2001 From: EKR Date: Fri, 13 Sep 2013 10:11:44 -0700 Subject: [PATCH 38/43] Bug 916187. Part 1. Cleanup of trickle candidates and a test STUN server r=abr --- media/mtransport/test/ice_unittest.cpp | 14 + media/mtransport/test/stunserver.cpp | 430 +++++++++++++++++++++++++ media/mtransport/test/stunserver.h | 83 +++++ 3 files changed, 527 insertions(+) create mode 100644 media/mtransport/test/stunserver.cpp create mode 100644 media/mtransport/test/stunserver.h diff --git a/media/mtransport/test/ice_unittest.cpp b/media/mtransport/test/ice_unittest.cpp index f10340303c41..0e18383df183 100644 --- a/media/mtransport/test/ice_unittest.cpp +++ b/media/mtransport/test/ice_unittest.cpp @@ -31,6 +31,10 @@ #include "nrinterfaceprioritizer.h" #include "mtransport_test_utils.h" #include "runnable_utils.h" +#include "stunserver.h" +// TODO(bcampen@mozilla.com): Big fat hack since the build system doesn't give +// us a clean way to add object files to a single executable. +#include "stunserver.cpp" #define GTEST_HAS_RTTI 0 #include "gtest/gtest.h" @@ -586,6 +590,9 @@ class IceTestPeer : public sigslot::has_slots<> { class IceGatherTest : public ::testing::Test { public: void SetUp() { + test_utils->sts_target()->Dispatch(WrapRunnable(TestStunServer::GetInstance(), + &TestStunServer::Reset), + NS_DISPATCH_SYNC); peer_ = new IceTestPeer("P1", true, false); peer_->AddStream(1); } @@ -1148,7 +1155,14 @@ int main(int argc, char **argv) // Start the tests ::testing::InitGoogleTest(&argc, argv); + test_utils->sts_target()->Dispatch( + WrapRunnableNM(&TestStunServer::GetInstance), NS_DISPATCH_SYNC); + int rv = RUN_ALL_TESTS(); + + test_utils->sts_target()->Dispatch( + WrapRunnableNM(&TestStunServer::ShutdownInstance), NS_DISPATCH_SYNC); + delete test_utils; return rv; } diff --git a/media/mtransport/test/stunserver.cpp b/media/mtransport/test/stunserver.cpp new file mode 100644 index 000000000000..9253a7dff1c1 --- /dev/null +++ b/media/mtransport/test/stunserver.cpp @@ -0,0 +1,430 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Original author: ekr@rtfm.com + +/* +Original code from nICEr and nrappkit. + +nICEr copyright: + +Copyright (c) 2007, Adobe Systems, Incorporated +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Adobe Systems, Network Resonance nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +nrappkit copyright: + + Copyright (C) 2001-2003, Network Resonance, Inc. + Copyright (C) 2006, Network Resonance, Inc. + All Rights Reserved + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of Network Resonance, Inc. nor the name of any + contributors to this software may be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + + ekr@rtfm.com Thu Dec 20 20:14:49 2001 +*/ +#include "logging.h" +#include "mozilla/Scoped.h" +#include "databuffer.h" + +extern "C" { +#include "nr_api.h" +#include "async_wait.h" +#include "async_timer.h" +#include "nr_socket.h" +#include "nr_socket_local.h" +#include "transport_addr.h" +#include "addrs.h" +#include "local_addr.h" +#include "stun_util.h" +#include "registry.h" +} + +#include "stunserver.h" + +#include + +MOZ_MTLOG_MODULE("stunserver"); + +namespace mozilla { + +// Wrapper nr_socket which allows us to lie to the stun server about the +// IP address. +struct nr_socket_wrapped { + nr_socket *sock_; + nr_transport_addr addr_; +}; + +static int nr_socket_wrapped_destroy(void **objp) { + if (!objp || !*objp) + return 0; + + nr_socket_wrapped *wrapped = static_cast(*objp); + *objp = 0; + + delete wrapped; + + return 0; +} + +static int nr_socket_wrapped_sendto(void *obj, const void *msg, size_t len, int flags, + nr_transport_addr *addr) { + nr_socket_wrapped *wrapped = static_cast(obj); + + return nr_socket_sendto(wrapped->sock_, msg, len, flags, &wrapped->addr_); +} + +static int nr_socket_wrapped_recvfrom(void *obj, void * restrict buf, size_t maxlen, + size_t *len, int flags, nr_transport_addr *addr) { + MOZ_CRASH(); +} + +static int nr_socket_wrapped_getfd(void *obj, NR_SOCKET *fd) { + MOZ_CRASH(); +} + +static int nr_socket_wrapped_getaddr(void *obj, nr_transport_addr *addrp) { + nr_socket_wrapped *wrapped = static_cast(obj); + + return nr_socket_getaddr(wrapped->sock_, addrp); +} + +static int nr_socket_wrapped_close(void *obj) { + MOZ_CRASH(); +} + +static int nr_socket_wrapped_set_send_addr(nr_socket *sock, nr_transport_addr *addr) { + nr_socket_wrapped *wrapped = static_cast(sock->obj); + + return nr_transport_addr_copy(&wrapped->addr_, addr); +} + +static nr_socket_vtbl nr_socket_wrapped_vtbl = { + nr_socket_wrapped_destroy, + nr_socket_wrapped_sendto, + nr_socket_wrapped_recvfrom, + nr_socket_wrapped_getfd, + nr_socket_wrapped_getaddr, + nr_socket_wrapped_close +}; + +int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) { + ScopedDeletePtr wrapped(new nr_socket_wrapped()); + + wrapped->sock_ = inner; + + int r = nr_socket_create_int(wrapped.get(), &nr_socket_wrapped_vtbl, outp); + if (r) + return r; + + wrapped.forget(); + return 0; +} + + +// Instance static. +// Note: Calling Create() at static init time is not going to be safe, since +// we have no reason to expect this will be initted to a nullptr yet. +TestStunServer* TestStunServer::instance; +uint16_t TestStunServer::instance_port = 3478; + +TestStunServer::~TestStunServer() { + // TODO(ekr@rtfm.com): Put this on the right thread. + + // Unhook callback from our listen socket. + NR_SOCKET fd; + if (!nr_socket_getfd(listen_sock_, &fd)) { + NR_ASYNC_CANCEL(fd, NR_ASYNC_WAIT_READ); + } + + // Free up stun context and network resources + nr_stun_server_ctx_destroy(&stun_server_); + nr_socket_destroy(&listen_sock_); + nr_socket_destroy(&send_sock_); + + // Make sure we aren't still waiting on a deferred response timer to pop + if (timer_handle_) + NR_async_timer_cancel(timer_handle_); + + delete response_addr_; +} + +TestStunServer* TestStunServer::Create() { + NR_reg_init(NR_REG_MODE_LOCAL); + + ScopedDeletePtr server(new TestStunServer()); + + nr_local_addr addrs[100]; + int addr_ct; + int r; + + r = nr_stun_find_local_addresses(addrs, 100, &addr_ct); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't retrieve addresses"); + return nullptr; + } + + if (addr_ct < 1) { + MOZ_MTLOG(ML_ERROR, "No local addresses"); + return nullptr; + } + + // Bind to the first address (arbitrarily) on configured port (default 3478) + r = nr_transport_addr_set_port(&addrs[0].addr, instance_port); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't set port"); + return nullptr; + } + + r = nr_transport_addr_fmt_addr_string(&addrs[0].addr); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't re-set addr string"); + return nullptr; + } + + r = nr_socket_local_create(&addrs[0].addr, &server->listen_sock_); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't create listen socket"); + return nullptr; + } + + NR_SOCKET fd; + r = nr_socket_getfd(server->listen_sock_, &fd); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't get fd"); + return nullptr; + } + + r = nr_socket_wrapped_create(server->listen_sock_, &server->send_sock_); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't create send socket"); + return nullptr; + } + + r = nr_stun_server_ctx_create(const_cast("Test STUN server"), + server->send_sock_, + &server->stun_server_); + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't create STUN server"); + return nullptr; + } + + // Cache the address and port. + char addr_string[INET6_ADDRSTRLEN]; + r = nr_transport_addr_get_addrstring(&addrs[0].addr, addr_string, + sizeof(addr_string)); + if (r) { + MOZ_MTLOG(ML_ERROR, "Failed to convert listen addr to a string representation"); + return nullptr; + } + + server->listen_addr_ = addr_string; + server->listen_port_ = instance_port; + + NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server.get()); + + return server.forget(); +} + +void TestStunServer::ConfigurePort(uint16_t port) { + instance_port = port; +} + +TestStunServer* TestStunServer::GetInstance() { + if (!instance) + instance = Create(); + + return instance; +} + +void TestStunServer::ShutdownInstance() { + delete instance; + + instance = nullptr; +} + + +struct DeferredStunOperation { + DeferredStunOperation(TestStunServer *server, + const char *data, size_t len, + nr_transport_addr *addr) : + server_(server), + buffer_(reinterpret_cast(data), len) { + nr_transport_addr_copy(&addr_, addr); + } + + TestStunServer *server_; + DataBuffer buffer_; + nr_transport_addr addr_; +}; + +void TestStunServer::Process(const uint8_t *msg, size_t len, nr_transport_addr *addr) { + // Set the wrapped address so that the response goes to the right place. + nr_socket_wrapped_set_send_addr(send_sock_, addr); + nr_stun_server_process_request(stun_server_, send_sock_, + const_cast(reinterpret_cast(msg)), + len, + response_addr_ ? + response_addr_ : addr, + NR_STUN_AUTH_RULE_OPTIONAL); +} + +void TestStunServer::process_cb(NR_SOCKET s, int how, void *cb_arg) { + DeferredStunOperation *op = static_cast(cb_arg); + op->server_->timer_handle_ = nullptr; + op->server_->Process(op->buffer_.data(), op->buffer_.len(), &op->addr_); + + delete op; +} + +void TestStunServer::readable_cb(NR_SOCKET s, int how, void *cb_arg) { + TestStunServer* server = static_cast(cb_arg); + + char message[4096]; + size_t message_len; + nr_transport_addr addr; + + int r = nr_socket_recvfrom(server->listen_sock_, message, sizeof(message), + &message_len, 0, &addr); + + if (r) { + MOZ_MTLOG(ML_ERROR, "Couldn't read STUN message"); + return; + } + + MOZ_MTLOG(ML_DEBUG, "Received data of length " << message_len); + + // Re-arm. + NR_ASYNC_WAIT(s, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server); + + + // If we have initial dropping set, check at this point. + std::string key(addr.as_string); + + if (server->received_ct_.count(key) == 0) { + server->received_ct_[key] = 0; + } + + ++server->received_ct_[key]; + + if (!server->active_ || (server->received_ct_[key] <= server->initial_ct_)) { + MOZ_MTLOG(ML_DEBUG, "Dropping message #" + << server->received_ct_[key] << " from " << key); + return; + } + + if (server->delay_ms_) { + NR_ASYNC_TIMER_SET(server->delay_ms_, + process_cb, + new DeferredStunOperation( + server, + message, message_len, + &addr), + &server->timer_handle_); + } else { + server->Process(reinterpret_cast(message), message_len, &addr); + } +} + +void TestStunServer::SetActive(bool active) { + active_ = active; +} + +void TestStunServer::SetDelay(uint32_t delay_ms) { + delay_ms_ = delay_ms; +} + +void TestStunServer::SetDropInitialPackets(uint32_t count) { + initial_ct_ = count; +} + +nsresult TestStunServer::SetResponseAddr(nr_transport_addr *addr) { + delete response_addr_; + + response_addr_ = new nr_transport_addr(); + + int r = nr_transport_addr_copy(response_addr_, addr); + if (r) + return NS_ERROR_FAILURE; + + return NS_OK; +} + +nsresult TestStunServer::SetResponseAddr(const std::string& addr, + uint16_t port) { + nr_transport_addr addr2; + + int r = nr_ip4_str_port_to_transport_addr(addr.c_str(), + port, IPPROTO_UDP, + &addr2); + if (r) + return NS_ERROR_FAILURE; + + return SetResponseAddr(&addr2); +} + +void TestStunServer::Reset() { + delay_ms_ = 0; + if (timer_handle_) { + NR_async_timer_cancel(timer_handle_); + timer_handle_ = nullptr; + } + delete response_addr_; + response_addr_ = nullptr; +} + +} // close namespace diff --git a/media/mtransport/test/stunserver.h b/media/mtransport/test/stunserver.h new file mode 100644 index 000000000000..faccaa16fb12 --- /dev/null +++ b/media/mtransport/test/stunserver.h @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Original author: ekr@rtfm.com + +#ifndef stunserver_h__ +#define stunserver_h__ + +#include +#include +#include "prio.h" +#include "nsError.h" + +typedef struct nr_stun_server_ctx_ nr_stun_server_ctx; +typedef struct nr_socket_ nr_socket; + +namespace mozilla { + +class TestStunServer { + public: + // Generally, you should only call API in this class from the same thread that + // the initial |GetInstance| call was made from. + static TestStunServer *GetInstance(); + static void ShutdownInstance(); + // |ConfigurePort| will only have an effect if called before the first call + // to |GetInstance| (possibly following a |ShutdownInstance| call) + static void ConfigurePort(uint16_t port); + static TestStunServer *Create(); + + ~TestStunServer(); + + void SetActive(bool active); + void SetDelay(uint32_t delay_ms); + void SetDropInitialPackets(uint32_t count); + const std::string& addr() const { return listen_addr_; } + uint16_t port() const { return listen_port_; } + + // These should only be called from the same thread as the initial + // |GetInstance| call. + nsresult SetResponseAddr(nr_transport_addr *addr); + nsresult SetResponseAddr(const std::string& addr, uint16_t port); + + void Reset(); + + private: + TestStunServer() + : listen_sock_(nullptr), + send_sock_(nullptr), + stun_server_(nullptr), + active_(true), + delay_ms_(0), + initial_ct_(0), + response_addr_(nullptr), + timer_handle_(nullptr), + listen_port_(0) {} + + void Process(const uint8_t *msg, size_t len, nr_transport_addr *addr_in); + + static void readable_cb(NR_SOCKET sock, int how, void *cb_arg); + static void process_cb(NR_SOCKET sock, int how, void *cb_arg); + + nr_socket *listen_sock_; + nr_socket *send_sock_; + nr_stun_server_ctx *stun_server_; + bool active_; + uint32_t delay_ms_; + uint32_t initial_ct_; + nr_transport_addr *response_addr_; + void *timer_handle_; + std::map received_ct_; + std::string listen_addr_; + uint16_t listen_port_; + + static TestStunServer* instance; + static uint16_t instance_port; +}; + +} // End of namespace mozilla + +#endif From 451b545bef6c8737e96822bba6c1c504b3c6abb8 Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Wed, 18 Sep 2013 12:36:13 -0700 Subject: [PATCH 39/43] Bug 916187. Part 2. Using the test stun server, write some tests to exercise the checking logic written in 908740. r=abr --- media/mtransport/databuffer.h | 1 + media/mtransport/test/ice_unittest.cpp | 46 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/media/mtransport/databuffer.h b/media/mtransport/databuffer.h index f8f890b7f9a9..52fe33be0eee 100644 --- a/media/mtransport/databuffer.h +++ b/media/mtransport/databuffer.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace mozilla { diff --git a/media/mtransport/test/ice_unittest.cpp b/media/mtransport/test/ice_unittest.cpp index 0e18383df183..984ca3088c65 100644 --- a/media/mtransport/test/ice_unittest.cpp +++ b/media/mtransport/test/ice_unittest.cpp @@ -602,6 +602,28 @@ class IceGatherTest : public ::testing::Test { ASSERT_TRUE_WAIT(peer_->gathering_complete(), 10000); } + + void UseFakeStunServerWithResponse(const std::string& fake_addr, + uint16_t fake_port) { + TestStunServer::GetInstance()->SetResponseAddr(fake_addr, fake_port); + // Sets an additional stun server + peer_->SetStunServer(TestStunServer::GetInstance()->addr(), + TestStunServer::GetInstance()->port()); + } + + // NB: Only does substring matching, watch out for stuff like "1.2.3.4" + // matching "21.2.3.47". " 1.2.3.4 " should not have false positives. + bool StreamHasMatchingCandidate(unsigned int stream, + const std::string& match) { + std::vector candidates = peer_->GetCandidates(stream); + for (size_t c = 0; c < candidates.size(); ++c) { + if (std::string::npos != candidates[c].find(match)) { + return true; + } + } + return false; + } + protected: mozilla::ScopedDeletePtr peer_; }; @@ -876,6 +898,30 @@ TEST_F(IceGatherTest, TestBogusCandidate) { peer_->ParseCandidate(0, kBogusIceCandidate); } +TEST_F(IceGatherTest, VerifyTestStunServer) { + UseFakeStunServerWithResponse("192.0.2.133", 3333); + Gather(); + ASSERT_TRUE(StreamHasMatchingCandidate(0, " 192.0.2.133 3333 ")); +} + +TEST_F(IceGatherTest, TestStunServerReturnsWildcardAddr) { + UseFakeStunServerWithResponse("0.0.0.0", 3333); + Gather(); + ASSERT_FALSE(StreamHasMatchingCandidate(0, " 0.0.0.0 ")); +} + +TEST_F(IceGatherTest, TestStunServerReturnsPort0) { + UseFakeStunServerWithResponse("192.0.2.133", 0); + Gather(); + ASSERT_FALSE(StreamHasMatchingCandidate(0, " 192.0.2.133 0 ")); +} + +TEST_F(IceGatherTest, TestStunServerReturnsLoopbackAddr) { + UseFakeStunServerWithResponse("127.0.0.133", 3333); + Gather(); + ASSERT_FALSE(StreamHasMatchingCandidate(0, " 127.0.0.133 ")); +} + TEST_F(IceConnectTest, TestGather) { AddStream("first", 1); ASSERT_TRUE(Gather(true)); From 0e6a4ca6b9d4ec179582c2216cde1ee6af8fdd3c Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Wed, 18 Sep 2013 12:54:38 -0700 Subject: [PATCH 40/43] Bug 916187. Part 3. Double checking for leaks in new test stun server code, and fixing other things as I see them. r=abr --- media/mtransport/test/ice_unittest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/media/mtransport/test/ice_unittest.cpp b/media/mtransport/test/ice_unittest.cpp index 984ca3088c65..cfb6f98639c1 100644 --- a/media/mtransport/test/ice_unittest.cpp +++ b/media/mtransport/test/ice_unittest.cpp @@ -191,6 +191,7 @@ class IceTestPeer : public sigslot::has_slots<> { PRNetAddr addr; PRStatus status = PR_StringToNetAddr(kDefaultStunServerAddress.c_str(), &addr); + addr.inet.port = kDefaultStunServerPort; ASSERT_EQ(PR_SUCCESS, status); fake_resolver_.SetAddr(kDefaultStunServerHostname, addr); ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetResolver( From aff2242ca93a9646f2baf2cf732493a53884ae86 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Thu, 19 Sep 2013 13:11:30 -0400 Subject: [PATCH 41/43] bug 918378 - restrict WiFi permissions to nightly and aurora r=mfinkle --HG-- extra : rebase_source : 93f39055a6a52d7fd632bcbef4e62c46003a9d54 --- mobile/android/base/AndroidManifest.xml.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 07b1754fc727..8021c7f547d8 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -16,8 +16,10 @@ #include ../services/manifests/HealthReportAndroidManifest_permissions.xml.in #include ../services/manifests/SyncAndroidManifest_permissions.xml.in +#ifndef RELEASE_BUILD +#endif From 00bfcedc5888d8e41c72f8b8a8f1289c8e8ce103 Mon Sep 17 00:00:00 2001 From: Malini Das Date: Thu, 19 Sep 2013 13:35:19 -0400 Subject: [PATCH 42/43] Bug 779284 - Implement B2G Modal dialog handling to Marionette, r=jgriffin,mdas --- .../tests/unit/test_switch_remote_frame.py | 30 ++ testing/marionette/jar.mn | 1 + .../marionette/marionette-frame-manager.js | 198 ++++++++++++ testing/marionette/marionette-listener.js | 295 ++++++++++-------- testing/marionette/marionette-server.js | 159 +++------- 5 files changed, 450 insertions(+), 233 deletions(-) create mode 100644 testing/marionette/marionette-frame-manager.js diff --git a/testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py b/testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py index 41deecca2136..df5c1e86ce5f 100644 --- a/testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py +++ b/testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py @@ -46,6 +46,36 @@ class TestSwitchRemoteFrame(MarionetteTestCase): """) self.assertFalse(main_process) + def test_remote_frame_revisit(self): + # test if we can revisit a remote frame (this takes a different codepath) + self.marionette.navigate(self.marionette.absolute_url("test.html")) + self.marionette.execute_script("SpecialPowers.addPermission('browser', true, document)") + self.marionette.execute_script(""" + let iframe = document.createElement("iframe"); + SpecialPowers.wrap(iframe).mozbrowser = true; + SpecialPowers.wrap(iframe).remote = true; + iframe.id = "remote_iframe"; + iframe.style.height = "100px"; + iframe.style.width = "100%%"; + iframe.src = "%s"; + document.body.appendChild(iframe); + """ % self.marionette.absolute_url("test.html")) + self.marionette.switch_to_frame("remote_iframe") + main_process = self.marionette.execute_script(""" + return SpecialPowers.isMainProcess(); + """) + self.assertFalse(main_process) + self.marionette.switch_to_frame() + main_process = self.marionette.execute_script(""" + return SpecialPowers.isMainProcess(); + """) + self.assertTrue(main_process) + self.marionette.switch_to_frame("remote_iframe") + main_process = self.marionette.execute_script(""" + return SpecialPowers.isMainProcess(); + """) + self.assertFalse(main_process) + def tearDown(self): if self.oop_by_default is None: self.marionette.execute_script(""" diff --git a/testing/marionette/jar.mn b/testing/marionette/jar.mn index d3d2af698838..9b957cedf196 100644 --- a/testing/marionette/jar.mn +++ b/testing/marionette/jar.mn @@ -10,6 +10,7 @@ marionette.jar: content/marionette-sendkeys.js (marionette-sendkeys.js) content/marionette-common.js (marionette-common.js) content/marionette-simpletest.js (marionette-simpletest.js) + content/marionette-frame-manager.js (marionette-frame-manager.js) content/EventUtils.js (EventUtils.js) content/ChromeUtils.js (ChromeUtils.js) #ifdef ENABLE_TESTS diff --git a/testing/marionette/marionette-frame-manager.js b/testing/marionette/marionette-frame-manager.js new file mode 100644 index 000000000000..3e1c0f298d79 --- /dev/null +++ b/testing/marionette/marionette-frame-manager.js @@ -0,0 +1,198 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +this.EXPORTED_SYMBOLS = [ + "FrameManager" +]; + +let FRAME_SCRIPT = "chrome://marionette/content/marionette-listener.js"; +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +Cu.import("resource://gre/modules/services-common/log4moz.js"); +let logger = Log4Moz.repository.getLogger("Marionette"); + +//list of OOP frames that has the frame script loaded +let remoteFrames = []; + +/** + * An object representing a frame that Marionette has loaded a + * frame script in. + */ +function MarionetteRemoteFrame(windowId, frameId) { + this.windowId = windowId; //outerWindowId relative to main process + this.frameId = frameId ? frameId : null; //actual frame relative to windowId's frames list + this.targetFrameId = this.frameId; //assigned FrameId, used for messaging +}; + +/** + * The FrameManager will maintain the list of Out Of Process (OOP) frames and will handle + * frame switching between them. + * It handles explicit frame switching (switchToFrame), and implicit frame switching, which + * occurs when a modal dialog is triggered in B2G. + * + */ +this.FrameManager = function FrameManager(server) { + //messageManager maintains the messageManager for the current process' chrome frame or the global message manager + this.currentRemoteFrame = null; //holds a member of remoteFrames (for an OOP frame) or null (for the main process) + this.previousRemoteFrame = null; //frame we'll need to restore once interrupt is gone + this.handledModal = false; //set to true when we have been interrupted by a modal + this.server = server; // a reference to the marionette server +}; + +FrameManager.prototype = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsIMessageListener, + Ci.nsISupportsWeakReference]), + + /** + * Receives all messages from content messageManager + */ + receiveMessage: function FM_receiveMessage(message) { + switch (message.name) { + case "MarionetteFrame:getInterruptedState": + // This will return true if the calling frame was interrupted by a modal dialog + if (this.previousRemoteFrame) { + let interruptedFrame = Services.wm.getOuterWindowWithId(this.previousRemoteFrame.windowId);//get the frame window of the interrupted frame + if (this.previousRemoteFrame.frameId != null) { + interruptedFrame = interruptedFrame.document.getElementsByTagName("iframe")[this.previousRemoteFrame.frameId]; //find the OOP frame + } + //check if the interrupted frame is the same as the calling frame + if (interruptedFrame.src == message.target.src) { + return {value: this.handledModal}; + } + } + else if (this.currentRemoteFrame == null) { + // we get here if previousRemoteFrame and currentRemoteFrame are null, ie: if we're in a non-OOP process, or we haven't switched into an OOP frame, in which case, handledModal can't be set to true. + return {value: this.handledModal}; + } + return {value: false}; + case "MarionetteFrame:handleModal": + /* + * handleModal is called when we need to switch frames to the main process due to a modal dialog interrupt. + */ + // If previousRemoteFrame was set, that means we switched into a remote frame. + // If this is the case, then we want to switch back into the system frame. + // If it isn't the case, then we're in a non-OOP environment, so we don't need to handle remote frames + let isLocal = true; + if (this.currentRemoteFrame != null) { + isLocal = false; + this.removeMessageManagerListeners(this.currentRemoteFrame.messageManager.get()); + //store the previous frame so we can switch back to it when the modal is dismissed + this.previousRemoteFrame = this.currentRemoteFrame; + //by setting currentRemoteFrame to null, it signifies we're in the main process + this.currentRemoteFrame = null; + this.server.messageManager = Cc["@mozilla.org/globalmessagemanager;1"] + .getService(Ci.nsIMessageBroadcaster); + } + this.handledModal = true; + this.server.sendOk(this.server.command_id); + return {value: isLocal}; + } + }, + + //This is just 'switch to OOP frame'. We're handling this here so we can maintain a list of remoteFrames. + switchToFrame: function FM_switchToFrame(message) { + // Switch to a remote frame. + let frameWindow = Services.wm.getOuterWindowWithId(message.json.win); //get the original frame window + let oopFrame = frameWindow.document.getElementsByTagName("iframe")[message.json.frame]; //find the OOP frame + let mm = oopFrame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager; //get the OOP frame's mm + + // See if this frame already has our frame script loaded in it; if so, + // just wake it up. + for (let i = 0; i < remoteFrames.length; i++) { + let frame = remoteFrames[i]; + let frameMessageManager = frame.messageManager.get(); + logger.info("trying remote frame " + i); + try { + frameMessageManager.sendAsyncMessage("aliveCheck", {}); + } + catch(e) { + if (e.result == Components.results.NS_ERROR_NOT_INITIALIZED) { + logger.info("deleting frame"); + remoteFrames.splice(i, 1); + continue; + } + } + if (frameMessageManager == mm) { + this.currentRemoteFrame = frame; + this.addMessageManagerListeners(mm); + mm.sendAsyncMessage("Marionette:restart", {}); + return; + } + } + + // If we get here, then we need to load the frame script in this frame, + // and set the frame's ChromeMessageSender as the active message manager the server will listen to + this.addMessageManagerListeners(mm); + logger.info("frame-manager load script: " + mm.toString()); + mm.loadFrameScript(FRAME_SCRIPT, true); + let aFrame = new MarionetteRemoteFrame(message.json.win, message.json.frame); + aFrame.messageManager = Cu.getWeakReference(mm); + remoteFrames.push(aFrame); + this.currentRemoteFrame = aFrame; + }, + + /* + * This function handles switching back to the frame that was interrupted by the modal dialog. + * This function gets called by the interrupted frame once the dialog is dismissed and the frame resumes its process + */ + switchToModalOrigin: function FM_switchToModalOrigin() { + //only handle this if we indeed switched out of the modal's originating frame + if (this.previousRemoteFrame != null) { + this.currentRemoteFrame = this.previousRemoteFrame; + this.addMessageManagerListeners(this.currentRemoteFrame.messageManager.get()); + } + this.handledModal = false; + }, + + /** + * Adds message listeners to the server, listening for messages from content frame scripts. + * It also adds a "MarionetteFrame:getInterruptedState" message listener to the FrameManager, + * so the frame manager's state can be checked by the frame + * + * @param object messageManager + * The messageManager object (ChromeMessageBroadcaster or ChromeMessageSender) + * to which the listeners should be added. + */ + addMessageManagerListeners: function MDA_addMessageManagerListeners(messageManager) { + messageManager.addWeakMessageListener("Marionette:ok", this.server); + messageManager.addWeakMessageListener("Marionette:done", this.server); + messageManager.addWeakMessageListener("Marionette:error", this.server); + messageManager.addWeakMessageListener("Marionette:log", this.server); + messageManager.addWeakMessageListener("Marionette:shareData", this.server); + messageManager.addWeakMessageListener("Marionette:register", this.server); + messageManager.addWeakMessageListener("Marionette:runEmulatorCmd", this.server); + messageManager.addWeakMessageListener("Marionette:switchToModalOrigin", this.server); + messageManager.addWeakMessageListener("Marionette:switchToFrame", this.server); + messageManager.addWeakMessageListener("Marionette:switchedToFrame", this.server); + messageManager.addWeakMessageListener("MarionetteFrame:handleModal", this); + messageManager.addWeakMessageListener("MarionetteFrame:getInterruptedState", this); + }, + + /** + * Removes listeners for messages from content frame scripts. + * We do not remove the "MarionetteFrame:getInterruptedState" or the + * "Marioentte:switchToModalOrigin" message listener, + * because we want to allow all known frames to contact the frame manager so that + * it can check if it was interrupted, and if so, it will call switchToModalOrigin + * when its process gets resumed. + * + * @param object messageManager + * The messageManager object (ChromeMessageBroadcaster or ChromeMessageSender) + * from which the listeners should be removed. + */ + removeMessageManagerListeners: function MDA_removeMessageManagerListeners(messageManager) { + messageManager.removeWeakMessageListener("Marionette:ok", this.server); + messageManager.removeWeakMessageListener("Marionette:done", this.server); + messageManager.removeWeakMessageListener("Marionette:error", this.server); + messageManager.removeWeakMessageListener("Marionette:log", this.server); + messageManager.removeWeakMessageListener("Marionette:shareData", this.server); + messageManager.removeWeakMessageListener("Marionette:register", this.server); + messageManager.removeWeakMessageListener("Marionette:runEmulatorCmd", this.server); + messageManager.removeWeakMessageListener("Marionette:switchToFrame", this.server); + messageManager.removeWeakMessageListener("Marionette:switchedToFrame", this.server); + messageManager.removeWeakMessageListener("MarionetteFrame:handleModal", this); + }, + +}; diff --git a/testing/marionette/marionette-listener.js b/testing/marionette/marionette-listener.js index 95138504aa87..777d160ac1b9 100644 --- a/testing/marionette/marionette-listener.js +++ b/testing/marionette/marionette-listener.js @@ -36,8 +36,8 @@ let marionetteTestName; let winUtil = content.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); let listenerId = null; //unique ID of this listener -let activeFrame = null; -let curWindow = content; +let curFrame = content; +let previousFrame = null; let elementManager = new ElementManager([]); let importedScripts = null; @@ -75,6 +75,15 @@ let mouseEventsOnly = false; Cu.import("resource://gre/modules/services-common/log4moz.js"); let logger = Log4Moz.repository.getLogger("Marionette"); logger.info("loaded marionette-listener.js"); +let modalHandler = function() { + sendSyncMessage("Marionette:switchedToFrame", { frameValue: null, storePrevious: true }); + let isLocal = sendSyncMessage("MarionetteFrame:handleModal", {})[0].value; + if (isLocal) { + previousFrame = curFrame; + } + curFrame = content; + sandbox = null; +}; /** * Called when listener is first started up. @@ -160,6 +169,7 @@ function startListeners() { function newSession(msg) { isB2G = msg.json.B2G; resetValues(); + content.addEventListener("mozbrowsershowmodalprompt", modalHandler, false); } /** @@ -177,6 +187,7 @@ function sleepSession(msg) { */ function restart(msg) { removeMessageListener("Marionette:restart", restart); + content.addEventListener("mozbrowsershowmodalprompt", modalHandler, false); registerSelf(); } @@ -224,10 +235,11 @@ function deleteSession(msg) { removeMessageListenerId("Marionette:getAllCookies", getAllCookies); removeMessageListenerId("Marionette:deleteAllCookies", deleteAllCookies); removeMessageListenerId("Marionette:deleteCookie", deleteCookie); + content.removeEventListener("mozbrowsershowmodalprompt", modalHandler, false); this.elementManager.reset(); // reset frame to the top-most frame - curWindow = content; - curWindow.focus(); + curFrame = content; + curFrame.focus(); touchIds = {}; } @@ -279,7 +291,7 @@ function sendError(message, status, trace, command_id) { */ function resetValues() { sandbox = null; - curWindow = content; + curFrame = content; mouseEventsOnly = false; } @@ -290,6 +302,22 @@ function dumpLog(logline) { dump(Date.now() + " Marionette: " + logline); } +/** + * Check if our context was interrupted + */ +function wasInterrupted() { + if (previousFrame) { + let element = content.document.elementFromPoint((content.innerWidth/2), (content.innerHeight/2)); + if (element.id.indexOf("modal-dialog") == -1) { + return true; + } + else { + return false; + } + } + return sendSyncMessage("MarionetteFrame:getInterruptedState", {})[0].value; +} + /* * Marionette Methods */ @@ -326,11 +354,11 @@ function createExecuteContentSandbox(aWindow, timeout) { sandbox.asyncComplete = function sandbox_asyncComplete(value, status, stack, commandId) { if (commandId == asyncTestCommandId) { - curWindow.removeEventListener("unload", onunload, false); - curWindow.clearTimeout(asyncTestTimeoutId); + curFrame.removeEventListener("unload", onunload, false); + curFrame.clearTimeout(asyncTestTimeoutId); if (inactivityTimeoutId != null) { - curWindow.clearTimeout(inactivityTimeoutId); + curFrame.clearTimeout(inactivityTimeoutId); } @@ -381,14 +409,14 @@ function executeScript(msg, directInject) { // Set up inactivity timeout. if (msg.json.inactivityTimeout) { let setTimer = function() { - inactivityTimeoutId = curWindow.setTimeout(function() { + inactivityTimeoutId = curFrame.setTimeout(function() { sendError('timed out due to inactivity', 28, null, asyncTestCommandId); }, msg.json.inactivityTimeout); }; setTimer(); heartbeatCallback = function resetInactivityTimeout() { - curWindow.clearTimeout(inactivityTimeoutId); + curFrame.clearTimeout(inactivityTimeoutId); setTimer(); }; } @@ -397,7 +425,7 @@ function executeScript(msg, directInject) { let script = msg.json.value; if (msg.json.newSandbox || !sandbox) { - sandbox = createExecuteContentSandbox(curWindow, + sandbox = createExecuteContentSandbox(curFrame, msg.json.timeout); if (!sandbox) { sendError("Could not create sandbox!", 500, null, asyncTestCommandId); @@ -432,7 +460,7 @@ function executeScript(msg, directInject) { else { try { sandbox.__marionetteParams = elementManager.convertWrappedArguments( - msg.json.args, curWindow); + msg.json.args, curFrame); } catch(e) { sendError(e.message, e.code, e.stack, asyncTestCommandId); @@ -505,14 +533,14 @@ function executeWithCallback(msg, useFinish) { // Set up inactivity timeout. if (msg.json.inactivityTimeout) { let setTimer = function() { - inactivityTimeoutId = curWindow.setTimeout(function() { + inactivityTimeoutId = curFrame.setTimeout(function() { sandbox.asyncComplete('timed out due to inactivity', 28, null, asyncTestCommandId); }, msg.json.inactivityTimeout); }; setTimer(); heartbeatCallback = function resetInactivityTimeout() { - curWindow.clearTimeout(inactivityTimeoutId); + curFrame.clearTimeout(inactivityTimeoutId); setTimer(); }; } @@ -523,10 +551,10 @@ function executeWithCallback(msg, useFinish) { onunload = function() { sendError("unload was called", 17, null, asyncTestCommandId); }; - curWindow.addEventListener("unload", onunload, false); + curFrame.addEventListener("unload", onunload, false); if (msg.json.newSandbox || !sandbox) { - sandbox = createExecuteContentSandbox(curWindow, + sandbox = createExecuteContentSandbox(curFrame, msg.json.timeout); if (!sandbox) { sendError("Could not create sandbox!", 17, null, asyncTestCommandId); @@ -543,14 +571,14 @@ function executeWithCallback(msg, useFinish) { // However Selenium code returns 28, see // http://code.google.com/p/selenium/source/browse/trunk/javascript/firefox-driver/js/evaluate.js. // We'll stay compatible with the Selenium code. - asyncTestTimeoutId = curWindow.setTimeout(function() { + asyncTestTimeoutId = curFrame.setTimeout(function() { sandbox.asyncComplete('timed out', 28, null, asyncTestCommandId); }, msg.json.timeout); - originalOnError = curWindow.onerror; - curWindow.onerror = function errHandler(errMsg, url, line) { + originalOnError = curFrame.onerror; + curFrame.onerror = function errHandler(errMsg, url, line) { sandbox.asyncComplete(errMsg, 17, "@" + url + ", line " + line, asyncTestCommandId); - curWindow.onerror = originalOnError; + curFrame.onerror = originalOnError; }; let scriptSrc; @@ -563,7 +591,7 @@ function executeWithCallback(msg, useFinish) { else { try { sandbox.__marionetteParams = elementManager.convertWrappedArguments( - msg.json.args, curWindow); + msg.json.args, curFrame); } catch(e) { sendError(e.message, e.code, e.stack, asyncTestCommandId); @@ -600,17 +628,19 @@ function executeWithCallback(msg, useFinish) { * This function creates a touch event given a touch type and a touch */ function emitTouchEvent(type, touch) { - let loggingInfo = "emitting Touch event of type " + type + " to element with id: " + touch.target.id + " and tag name: " + touch.target.tagName + " at coordinates (" + touch.clientX + ", " + touch.clientY + ") relative to the viewport"; - dumpLog(loggingInfo); - /* - Disabled per bug 888303 - marionetteLogObj.log(loggingInfo, "TRACE"); - sendSyncMessage("Marionette:shareData", - {log: elementManager.wrapValue(marionetteLogObj.getLogs())}); - marionetteLogObj.clearLogs(); - */ - let domWindowUtils = curWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils); - domWindowUtils.sendTouchEvent(type, [touch.identifier], [touch.screenX], [touch.screenY], [touch.radiusX], [touch.radiusY], [touch.rotationAngle], [touch.force], 1, 0); + if (!wasInterrupted()) { + let loggingInfo = "emitting Touch event of type " + type + " to element with id: " + touch.target.id + " and tag name: " + touch.target.tagName + " at coordinates (" + touch.clientX + ", " + touch.clientY + ") relative to the viewport"; + dumpLog(loggingInfo); + /* + Disabled per bug 888303 + marionetteLogObj.log(loggingInfo, "TRACE"); + sendSyncMessage("Marionette:shareData", + {log: elementManager.wrapValue(marionetteLogObj.getLogs())}); + marionetteLogObj.clearLogs(); + */ + let domWindowUtils = curFrame.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils); + domWindowUtils.sendTouchEvent(type, [touch.identifier], [touch.screenX], [touch.screenY], [touch.radiusX], [touch.radiusY], [touch.rotationAngle], [touch.force], 1, 0); + } } /** @@ -621,20 +651,22 @@ function emitTouchEvent(type, touch) { * elClientX and elClientY are the coordinates of the mouse relative to the viewport */ function emitMouseEvent(doc, type, elClientX, elClientY, detail, button) { - let loggingInfo = "emitting Mouse event of type " + type + " at coordinates (" + elClientX + ", " + elClientY + ") relative to the viewport"; - dumpLog(loggingInfo); - /* - Disabled per bug 888303 - marionetteLogObj.log(loggingInfo, "TRACE"); - sendSyncMessage("Marionette:shareData", - {log: elementManager.wrapValue(marionetteLogObj.getLogs())}); - marionetteLogObj.clearLogs(); - */ - detail = detail || 1; - button = button || 0; - let win = doc.defaultView; - // Figure out the element the mouse would be over at (x, y) - utils.synthesizeMouseAtPoint(elClientX, elClientY, {type: type, button: button, clickCount: detail}, win); + if (!wasInterrupted()) { + let loggingInfo = "emitting Mouse event of type " + type + " at coordinates (" + elClientX + ", " + elClientY + ") relative to the viewport"; + dumpLog(loggingInfo); + /* + Disabled per bug 888303 + marionetteLogObj.log(loggingInfo, "TRACE"); + sendSyncMessage("Marionette:shareData", + {log: elementManager.wrapValue(marionetteLogObj.getLogs())}); + marionetteLogObj.clearLogs(); + */ + detail = detail || 1; + button = button || 0; + let win = doc.defaultView; + // Figure out the element the mouse would be over at (x, y) + utils.synthesizeMouseAtPoint(elClientX, elClientY, {type: type, button: button, clickCount: detail}, win); + } } /** @@ -672,14 +704,14 @@ function coordinates(target, x, y) { */ function elementInViewport(el) { let rect = el.getBoundingClientRect(); - let viewPort = {top: curWindow.pageYOffset, - left: curWindow.pageXOffset, - bottom: (curWindow.pageYOffset + curWindow.innerHeight), - right:(curWindow.pageXOffset + curWindow.innerWidth)}; - return (viewPort.left <= rect.right + curWindow.pageXOffset && - rect.left + curWindow.pageXOffset <= viewPort.right && - viewPort.top <= rect.bottom + curWindow.pageYOffset && - rect.top + curWindow.pageYOffset <= viewPort.bottom); + let viewPort = {top: curFrame.pageYOffset, + left: curFrame.pageXOffset, + bottom: (curFrame.pageYOffset + curFrame.innerHeight), + right:(curFrame.pageXOffset + curFrame.innerWidth)}; + return (viewPort.left <= rect.right + curFrame.pageXOffset && + rect.left + curFrame.pageXOffset <= viewPort.right && + viewPort.top <= rect.bottom + curFrame.pageYOffset && + rect.top + curFrame.pageYOffset <= viewPort.bottom); } /** @@ -712,7 +744,7 @@ function checkVisible(el) { //x and y are coordinates relative to the viewport function generateEvents(type, x, y, touchId, target) { lastCoordinates = [x, y]; - let doc = curWindow.document; + let doc = curFrame.document; switch (type) { case 'tap': if (mouseEventsOnly) { @@ -781,7 +813,7 @@ function generateEvents(type, x, y, touchId, target) { break; case 'contextmenu': isTap = false; - let event = curWindow.document.createEvent('HTMLEvents'); + let event = curFrame.document.createEvent('HTMLEvents'); event.initEvent('contextmenu', true, true); if (mouseEventsOnly) { target = doc.elementFromPoint(lastCoordinates[0], lastCoordinates[1]); @@ -794,6 +826,19 @@ function generateEvents(type, x, y, touchId, target) { default: throw {message:"Unknown event type: " + type, code: 500, stack:null}; } + if (wasInterrupted()) { + if (previousFrame) { + //if previousFrame is set, then we're in a single process environment + curFrame = previousFrame; + previousFrame = null; + sandbox = null; + } + else { + //else we're in OOP environment, so we'll switch to the original OOP frame + sendSyncMessage("Marionette:switchToModalOrigin"); + } + sendSyncMessage("Marionette:switchedToFrame", { restorePrevious: true }); + } } /** @@ -802,13 +847,13 @@ function generateEvents(type, x, y, touchId, target) { function singleTap(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.value, curWindow); + let el = elementManager.getKnownElement(msg.json.value, curFrame); // after this block, the element will be scrolled into view if (!checkVisible(el)) { sendError("Element is not currently visible and may not be manipulated", 11, null, command_id); return; } - if (!curWindow.document.createTouch) { + if (!curFrame.document.createTouch) { mouseEventsOnly = true; } let c = coordinates(el, msg.json.corx, msg.json.cory); @@ -868,7 +913,7 @@ function actions(chain, touchId, command_id, i) { sendError("Invalid Command: press cannot follow an active touch event", 500, null, command_id); return; } - el = elementManager.getKnownElement(pack[1], curWindow); + el = elementManager.getKnownElement(pack[1], curFrame); if (!checkVisible(el)) { sendError("Element is not currently visible and may not be manipulated", 11, null, command_id); return; @@ -882,7 +927,7 @@ function actions(chain, touchId, command_id, i) { actions(chain, null, command_id, i); break; case 'move': - el = elementManager.getKnownElement(pack[1], curWindow); + el = elementManager.getKnownElement(pack[1], curFrame); c = coordinates(el); generateEvents('move', c.x, c.y, touchId); actions(chain, touchId, command_id, i); @@ -929,12 +974,12 @@ function actionChain(msg) { let args = msg.json.chain; let touchId = msg.json.nextId; try { - let commandArray = elementManager.convertWrappedArguments(args, curWindow); + let commandArray = elementManager.convertWrappedArguments(args, curFrame); // loop the action array [ ['press', id], ['move', id], ['release', id] ] if (touchId == null) { touchId = nextTouchId++; } - if (!curWindow.document.createTouch) { + if (!curFrame.document.createTouch) { mouseEventsOnly = true; } actions(commandArray, touchId, command_id); @@ -963,7 +1008,7 @@ function emitMultiEvents(type, touch, touches) { // Create changed touches let changedTouches = doc.createTouchList(touch); // Create the event object - let event = curWindow.document.createEvent('TouchEvent'); + let event = curFrame.document.createEvent('TouchEvent'); event.initTouchEvent(type, true, true, @@ -1016,7 +1061,7 @@ function setDispatch(batches, touches, command_id, batchIndex) { command = pack[1]; switch (command) { case 'press': - el = elementManager.getKnownElement(pack[2], curWindow); + el = elementManager.getKnownElement(pack[2], curFrame); c = coordinates(el, pack[3], pack[4]); touch = createATouch(el, c.x, c.y, touchId); multiLast[touchId] = touch; @@ -1031,7 +1076,7 @@ function setDispatch(batches, touches, command_id, batchIndex) { emitMultiEvents('touchend', touch, touches); break; case 'move': - el = elementManager.getKnownElement(pack[2], curWindow); + el = elementManager.getKnownElement(pack[2], curFrame); c = coordinates(el); touch = createATouch(multiLast[touchId].target, c.x, c.y, touchId); touchIndex = touches.indexOf(lastTouch); @@ -1085,7 +1130,7 @@ function multiAction(msg) { let maxlen = msg.json.maxlen; try { // unwrap the original nested array - let commandArray = elementManager.convertWrappedArguments(args, curWindow); + let commandArray = elementManager.convertWrappedArguments(args, curFrame); let concurrentEvent = []; let temp; for (let i = 0; i < maxlen; i++) { @@ -1127,11 +1172,11 @@ function goUrl(msg) { let errorRegex = /about:.+(error)|(blocked)\?/; let elapse = end - start; if (msg.json.pageTimeout == null || elapse <= msg.json.pageTimeout){ - if (curWindow.document.readyState == "complete"){ + if (curFrame.document.readyState == "complete"){ removeEventListener("DOMContentLoaded", onDOMContentLoaded, false); sendOk(command_id); } - else if (curWindow.document.readyState == "interactive" && errorRegex.exec(curWindow.document.baseURI)){ + else if (curFrame.document.readyState == "interactive" && errorRegex.exec(curFrame.document.baseURI)){ removeEventListener("DOMContentLoaded", onDOMContentLoaded, false); sendError("Error loading page", 13, null, command_id); } @@ -1149,7 +1194,7 @@ function goUrl(msg) { // window (i.e., someone has used switch_to_frame). let onDOMContentLoaded = function onDOMContentLoaded(event){ if (!event.originalTarget.defaultView.frameElement || - event.originalTarget.defaultView.frameElement == curWindow.frameElement) { + event.originalTarget.defaultView.frameElement == curFrame.frameElement) { checkLoad(); } }; @@ -1162,29 +1207,29 @@ function goUrl(msg) { checkTimer.initWithCallback(timerFunc, msg.json.pageTimeout, Ci.nsITimer.TYPE_ONE_SHOT); } addEventListener("DOMContentLoaded", onDOMContentLoaded, false); - curWindow.location = msg.json.value; + curFrame.location = msg.json.value; } /** * Get the current URI */ function getUrl(msg) { - sendResponse({value: curWindow.location.href}, msg.json.command_id); + sendResponse({value: curFrame.location.href}, msg.json.command_id); } /** * Get the current Title of the window */ function getTitle(msg) { - sendResponse({value: curWindow.top.document.title}, msg.json.command_id); + sendResponse({value: curFrame.top.document.title}, msg.json.command_id); } /** * Get the current page source */ function getPageSource(msg) { - var XMLSerializer = curWindow.XMLSerializer; - var pageSource = new XMLSerializer().serializeToString(curWindow.document); + var XMLSerializer = curFrame.XMLSerializer; + var pageSource = new XMLSerializer().serializeToString(curFrame.document); sendResponse({value: pageSource}, msg.json.command_id); } @@ -1192,7 +1237,7 @@ function getPageSource(msg) { * Go back in history */ function goBack(msg) { - curWindow.history.back(); + curFrame.history.back(); sendOk(msg.json.command_id); } @@ -1200,7 +1245,7 @@ function goBack(msg) { * Go forward in history */ function goForward(msg) { - curWindow.history.forward(); + curFrame.history.forward(); sendOk(msg.json.command_id); } @@ -1209,7 +1254,7 @@ function goForward(msg) { */ function refresh(msg) { let command_id = msg.json.command_id; - curWindow.location.reload(true); + curFrame.location.reload(true); let listen = function() { removeEventListener("DOMContentLoaded", arguments.callee, false); sendOk(command_id); @@ -1225,7 +1270,7 @@ function findElementContent(msg) { try { let on_success = function(id, cmd_id) { sendResponse({value:id}, cmd_id); }; let on_error = sendError; - elementManager.find(curWindow, msg.json, msg.json.searchTimeout, + elementManager.find(curFrame, msg.json, msg.json.searchTimeout, on_success, on_error, false, command_id); } catch (e) { @@ -1241,7 +1286,7 @@ function findElementsContent(msg) { try { let on_success = function(id, cmd_id) { sendResponse({value:id}, cmd_id); }; let on_error = sendError; - elementManager.find(curWindow, msg.json, msg.json.searchTimeout, + elementManager.find(curFrame, msg.json, msg.json.searchTimeout, on_success, on_error, true, command_id); } catch (e) { @@ -1254,7 +1299,7 @@ function findElementsContent(msg) { */ function getActiveElement(msg) { let command_id = msg.json.command_id; - var element = curWindow.document.activeElement; + var element = curFrame.document.activeElement; var id = elementManager.addToKnownElements(element); sendResponse({value: id}, command_id); } @@ -1266,7 +1311,7 @@ function clickElement(msg) { let command_id = msg.json.command_id; let el; try { - el = elementManager.getKnownElement(msg.json.element, curWindow); + el = elementManager.getKnownElement(msg.json.element, curFrame); if (checkVisible(el)) { if (utils.isElementEnabled(el)) { utils.synthesizeMouseAtCenter(el, {}, el.ownerDocument.defaultView) @@ -1291,7 +1336,7 @@ function clickElement(msg) { function getElementAttribute(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); sendResponse({value: utils.getElementAttribute(el, msg.json.name)}, command_id); } @@ -1306,7 +1351,7 @@ function getElementAttribute(msg) { function getElementText(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); sendResponse({value: utils.getElementText(el)}, command_id); } catch (e) { @@ -1320,7 +1365,7 @@ function getElementText(msg) { function getElementTagName(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); sendResponse({value: el.tagName.toLowerCase()}, command_id); } catch (e) { @@ -1334,7 +1379,7 @@ function getElementTagName(msg) { function isElementDisplayed(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); sendResponse({value: utils.isElementDisplayed(el)}, command_id); } catch (e) { @@ -1354,8 +1399,8 @@ function getElementValueOfCssProperty(msg){ let command_id = msg.json.command_id; let propertyName = msg.json.propertyName; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); - sendResponse({value: curWindow.document.defaultView.getComputedStyle(el, null).getPropertyValue(propertyName)}, + let el = elementManager.getKnownElement(msg.json.element, curFrame); + sendResponse({value: curFrame.document.defaultView.getComputedStyle(el, null).getPropertyValue(propertyName)}, command_id); } catch (e) { @@ -1369,7 +1414,7 @@ function getElementValueOfCssProperty(msg){ function getElementSize(msg){ let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); let clientRect = el.getBoundingClientRect(); sendResponse({value: {width: clientRect.width, height: clientRect.height}}, command_id); @@ -1385,7 +1430,7 @@ function getElementSize(msg){ function isElementEnabled(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); sendResponse({value: utils.isElementEnabled(el)}, command_id); } catch (e) { @@ -1399,7 +1444,7 @@ function isElementEnabled(msg) { function isElementSelected(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); sendResponse({value: utils.isElementSelected(el)}, command_id); } catch (e) { @@ -1413,9 +1458,9 @@ function isElementSelected(msg) { function sendKeysToElement(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); if (checkVisible(el)) { - utils.type(curWindow.document, el, msg.json.value.join(""), true); + utils.type(curFrame.document, el, msg.json.value.join(""), true); sendOk(command_id); } else { @@ -1433,7 +1478,7 @@ function sendKeysToElement(msg) { function getElementPosition(msg) { let command_id = msg.json.command_id; try{ - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); let rect = el.getBoundingClientRect(); let location = {}; @@ -1453,7 +1498,7 @@ function getElementPosition(msg) { function clearElement(msg) { let command_id = msg.json.command_id; try { - let el = elementManager.getKnownElement(msg.json.element, curWindow); + let el = elementManager.getKnownElement(msg.json.element, curFrame); utils.clearElement(el); sendOk(command_id); } @@ -1468,27 +1513,27 @@ function clearElement(msg) { */ function switchToFrame(msg) { let command_id = msg.json.command_id; - function checkLoad() { + function checkLoad() { let errorRegex = /about:.+(error)|(blocked)\?/; - if (curWindow.document.readyState == "complete") { + if (curFrame.document.readyState == "complete") { sendOk(command_id); return; } - else if (curWindow.document.readyState == "interactive" && errorRegex.exec(curWindow.document.baseURI)) { + else if (curFrame.document.readyState == "interactive" && errorRegex.exec(curFrame.document.baseURI)) { sendError("Error loading page", 13, null, command_id); return; } checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT); } let foundFrame = null; - let frames = []; //curWindow.document.getElementsByTagName("iframe"); - let parWindow = null; //curWindow.QueryInterface(Ci.nsIInterfaceRequestor) - // Check of the curWindow reference is dead + let frames = []; //curFrame.document.getElementsByTagName("iframe"); + let parWindow = null; //curFrame.QueryInterface(Ci.nsIInterfaceRequestor) + // Check of the curFrame reference is dead try { - frames = curWindow.document.getElementsByTagName("iframe"); + frames = curFrame.document.getElementsByTagName("iframe"); //Until Bug 761935 lands, we won't have multiple nested OOP iframes. We will only have one. //parWindow will refer to the iframe above the nested OOP frame. - parWindow = curWindow.QueryInterface(Ci.nsIInterfaceRequestor) + parWindow = curFrame.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils).outerWindowID; } catch (e) { // We probably have a dead compartment so accessing it is going to make Firefox @@ -1501,9 +1546,9 @@ function switchToFrame(msg) { // returning to root frame sendSyncMessage("Marionette:switchedToFrame", { frameValue: null }); - curWindow = content; + curFrame = content; if(msg.json.focus == true) { - curWindow.focus(); + curFrame.focus(); } sandbox = null; checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT); @@ -1513,7 +1558,7 @@ function switchToFrame(msg) { if (elementManager.seenItems[msg.json.element] != undefined) { let wantedFrame; try { - wantedFrame = elementManager.getKnownElement(msg.json.element, curWindow); //HTMLIFrameElement + wantedFrame = elementManager.getKnownElement(msg.json.element, curFrame); //HTMLIFrameElement } catch(e) { sendError(e.message, e.code, e.stack, command_id); @@ -1521,7 +1566,7 @@ function switchToFrame(msg) { for (let i = 0; i < frames.length; i++) { // use XPCNativeWrapper to compare elements; see bug 834266 if (XPCNativeWrapper(frames[i]) == XPCNativeWrapper(wantedFrame)) { - curWindow = frames[i]; + curFrame = frames[i]; foundFrame = i; } } @@ -1545,13 +1590,13 @@ function switchToFrame(msg) { } if ((foundFrame == null) && (foundById != null)) { foundFrame = foundById; - curWindow = frames[foundFrame]; + curFrame = frames[foundFrame]; } break; case "number": if (frames[msg.json.value] != undefined) { foundFrame = msg.json.value; - curWindow = frames[foundFrame]; + curFrame = frames[foundFrame]; } break; } @@ -1565,21 +1610,21 @@ function switchToFrame(msg) { // send a synchronous message to let the server update the currently active // frame element (for getActiveFrame) - let frameValue = elementManager.wrapValue(curWindow.wrappedJSObject)['ELEMENT']; + let frameValue = elementManager.wrapValue(curFrame.wrappedJSObject)['ELEMENT']; sendSyncMessage("Marionette:switchedToFrame", { frameValue: frameValue }); - if (curWindow.contentWindow == null) { + if (curFrame.contentWindow == null) { // The frame we want to switch to is a remote (out-of-process) frame; // notify our parent to handle the switch. - curWindow = content; + curFrame = content; sendToServer('Marionette:switchToFrame', {frame: foundFrame, win: parWindow, command_id: command_id}); } else { - curWindow = curWindow.contentWindow; + curFrame = curFrame.contentWindow; if(msg.json.focus == true) { - curWindow.focus(); + curFrame.focus(); } checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT); } @@ -1598,11 +1643,11 @@ function addCookie(msg) { } if (!cookie.domain) { - var location = curWindow.document.location; + var location = curFrame.document.location; cookie.domain = location.hostname; } else { - var currLocation = curWindow.location; + var currLocation = curFrame.location; var currDomain = currLocation.host; if (currDomain.indexOf(cookie.domain) == -1) { sendError("You may only set cookies for the current domain", 24, null, msg.json.command_id); @@ -1616,7 +1661,7 @@ function addCookie(msg) { cookie.domain = cookie.domain.replace(/:\d+$/, ''); } - var document = curWindow.document; + var document = curFrame.document; if (!document || !document.contentType.match(/html/i)) { sendError('You may only set cookies on html documents', 25, null, msg.json.command_id); } @@ -1632,7 +1677,7 @@ function addCookie(msg) { */ function getAllCookies(msg) { var toReturn = []; - var cookies = getVisibleCookies(curWindow.location); + var cookies = getVisibleCookies(curFrame.location); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var expires = cookie.expires; @@ -1662,7 +1707,7 @@ function deleteCookie(msg) { var cookieManager = Cc['@mozilla.org/cookiemanager;1']. getService(Ci.nsICookieManager); - var cookies = getVisibleCookies(curWindow.location); + var cookies = getVisibleCookies(curFrame.location); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; if (cookie.name == toDelete) { @@ -1679,7 +1724,7 @@ function deleteCookie(msg) { function deleteAllCookies(msg) { let cookieManager = Cc['@mozilla.org/cookiemanager;1']. getService(Ci.nsICookieManager); - let cookies = getVisibleCookies(curWindow.location); + let cookies = getVisibleCookies(curFrame.location); for (let i = 0; i < cookies.length; i++) { let cookie = cookies[i]; cookieManager.remove(cookie.host, cookie.name, cookie.path, false); @@ -1720,7 +1765,7 @@ function getVisibleCookies(location) { } function getAppCacheStatus(msg) { - sendResponse({ value: curWindow.applicationCache.status }, + sendResponse({ value: curFrame.applicationCache.status }, msg.json.command_id); } @@ -1782,7 +1827,7 @@ function screenShot(msg) { let node = null; if (msg.json.element) { try { - node = elementManager.getKnownElement(msg.json.element, curWindow) + node = elementManager.getKnownElement(msg.json.element, curFrame) } catch (e) { sendResponse(e.message, e.code, e.stack, msg.json.command_id); @@ -1790,14 +1835,14 @@ function screenShot(msg) { } } else { - node = curWindow; + node = curFrame; } let highlights = msg.json.highlights; - var document = curWindow.document; + var document = curFrame.document; var rect, win, width, height, left, top; // node can be either a window or an arbitrary DOM node - if (node == curWindow) { + if (node == curFrame) { // node is a window win = node; width = win.innerWidth; @@ -1829,7 +1874,7 @@ function screenShot(msg) { ctx.save(); for (var i = 0; i < highlights.length; ++i) { - var elem = elementManager.getKnownElement(highlights[i], curWindow) + var elem = elementManager.getKnownElement(highlights[i], curFrame) rect = elem.getBoundingClientRect(); var offsetY = -top; diff --git a/testing/marionette/marionette-server.js b/testing/marionette/marionette-server.js index 65887ae4338e..1fc3c2f01fb8 100644 --- a/testing/marionette/marionette-server.js +++ b/testing/marionette/marionette-server.js @@ -15,6 +15,8 @@ let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"] .getService(Ci.mozIJSSubScriptLoader); loader.loadSubScript("chrome://marionette/content/marionette-simpletest.js"); loader.loadSubScript("chrome://marionette/content/marionette-common.js"); +Cu.import("resource://gre/modules/Services.jsm"); +loader.loadSubScript("chrome://marionette/content/marionette-frame-manager.js"); Cu.import("chrome://marionette/content/marionette-elements.js"); let utils = {}; loader.loadSubScript("chrome://marionette/content/EventUtils.js", utils); @@ -27,7 +29,6 @@ loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js", specialpowers.specialPowersObserver = new specialpowers.SpecialPowersObserver(); specialpowers.specialPowersObserver.init(); -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); @@ -76,20 +77,6 @@ Services.obs.addObserver(function() { systemMessageListenerReady = true; }, "system-message-listener-ready", false); -/** - * An object representing a frame that Marionette has loaded a - * frame script in. - */ -function MarionetteRemoteFrame(windowId, frameId) { - this.windowId = windowId; - this.frameId = frameId; - this.targetFrameId = null; - this.messageManager = null; - this.command_id = null; -} -// persistent list of remote frames that Marionette has loaded a frame script in -let remoteFrames = []; - /* * Custom exceptions */ @@ -146,19 +133,19 @@ function MarionetteServerConnection(aPrefix, aTransport, aServer) this.marionetteLog = new MarionetteLogObj(); this.command_id = null; this.mainFrame = null; //topmost chrome frame - this.curFrame = null; //subframe that currently has focus + this.curFrame = null; // chrome iframe that currently has focus this.importedScripts = FileUtils.getFile('TmpD', ['marionettescriptchrome']); - this.currentRemoteFrame = null; // a member of remoteFrames this.currentFrameElement = null; this.testName = null; this.mozBrowserClose = null; - - //register all message listeners - this.addMessageManagerListeners(this.messageManager); } MarionetteServerConnection.prototype = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsIMessageListener, + Ci.nsIObserver, + Ci.nsISupportsWeakReference]), + /** * Debugger transport callbacks: */ @@ -197,12 +184,12 @@ MarionetteServerConnection.prototype = { * which removes most of the message listeners from it as well. */ switchToGlobalMessageManager: function MDA_switchToGlobalMM() { - if (this.currentRemoteFrame !== null) { - this.removeMessageManagerListeners(this.messageManager); + if (this.curBrowser && this.curBrowser.frameManager.currentRemoteFrame !== null) { + this.curBrowser.frameManager.removeMessageManagerListeners(this.messageManager); this.sendAsync("sleepSession", null, null, true); + this.curBrowser.frameManager.currentRemoteFrame = null; } this.messageManager = this.globalMessageManager; - this.currentRemoteFrame = null; }, /** @@ -218,10 +205,10 @@ MarionetteServerConnection.prototype = { if (values instanceof Object && commandId) { values.command_id = commandId; } - if (this.currentRemoteFrame !== null) { + if (this.curBrowser.frameManager.currentRemoteFrame !== null) { try { this.messageManager.sendAsyncMessage( - "Marionette:" + name + this.currentRemoteFrame.targetFrameId, values); + "Marionette:" + name + this.curBrowser.frameManager.currentRemoteFrame.targetFrameId, values); } catch(e) { if (!ignoreFailure) { @@ -229,10 +216,10 @@ MarionetteServerConnection.prototype = { let error = e; switch(e.result) { case Components.results.NS_ERROR_FAILURE: - error = new FrameSendFailureError(this.currentRemoteFrame); + error = new FrameSendFailureError(this.curBrowser.frameManager.currentRemoteFrame); break; case Components.results.NS_ERROR_NOT_INITIALIZED: - error = new FrameSendNotInitializedError(this.currentRemoteFrame); + error = new FrameSendNotInitializedError(this.curBrowser.frameManager.currentRemoteFrame); break; default: break; @@ -249,44 +236,6 @@ MarionetteServerConnection.prototype = { return success; }, - /** - * Adds listeners for messages from content frame scripts. - * - * @param object messageManager - * The messageManager object (ChromeMessageBroadcaster or ChromeMessageSender) - * to which the listeners should be added. - */ - addMessageManagerListeners: function MDA_addMessageManagerListeners(messageManager) { - messageManager.addMessageListener("Marionette:ok", this); - messageManager.addMessageListener("Marionette:done", this); - messageManager.addMessageListener("Marionette:error", this); - messageManager.addMessageListener("Marionette:log", this); - messageManager.addMessageListener("Marionette:shareData", this); - messageManager.addMessageListener("Marionette:register", this); - messageManager.addMessageListener("Marionette:runEmulatorCmd", this); - messageManager.addMessageListener("Marionette:switchToFrame", this); - messageManager.addMessageListener("Marionette:switchedToFrame", this); - }, - - /** - * Removes listeners for messages from content frame scripts. - * - * @param object messageManager - * The messageManager object (ChromeMessageBroadcaster or ChromeMessageSender) - * from which the listeners should be removed. - */ - removeMessageManagerListeners: function MDA_removeMessageManagerListeners(messageManager) { - messageManager.removeMessageListener("Marionette:ok", this); - messageManager.removeMessageListener("Marionette:done", this); - messageManager.removeMessageListener("Marionette:error", this); - messageManager.removeMessageListener("Marionette:log", this); - messageManager.removeMessageListener("Marionette:shareData", this); - messageManager.removeMessageListener("Marionette:register", this); - messageManager.removeMessageListener("Marionette:runEmulatorCmd", this); - messageManager.removeMessageListener("Marionette:switchToFrame", this); - messageManager.removeMessageListener("Marionette:switchedToFrame", this); - }, - logRequest: function MDA_logRequest(type, data) { logger.debug("Got request: " + type + ", data: " + JSON.stringify(data) + ", id: " + this.command_id); }, @@ -431,7 +380,7 @@ MarionetteServerConnection.prototype = { * Returns the unique server-assigned ID of the window */ addBrowser: function MDA_addBrowser(win) { - let browser = new BrowserObj(win); + let browser = new BrowserObj(win, this); let winId = win.QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIDOMWindowUtils).outerWindowID; winId = winId + ((appName == "B2G") ? '-b2g' : ''); @@ -554,7 +503,6 @@ MarionetteServerConnection.prototype = { } } - this.switchToGlobalMessageManager(); if (!Services.prefs.getBoolPref("marionette.contentListener")) { waitForWindow.call(this); @@ -568,6 +516,7 @@ MarionetteServerConnection.prototype = { else { this.sendError("Session already running", 500, null, this.command_id); } + this.switchToGlobalMessageManager(); }, getSessionCapabilities: function MDA_getSessionCapabilities(){ @@ -1363,7 +1312,7 @@ MarionetteServerConnection.prototype = { } else { if ((!aRequest.value) && (!aRequest.element) && - (this.currentRemoteFrame !== null)) { + (this.curBrowser.frameManager.currentRemoteFrame !== null)) { // We're currently using a ChromeMessageSender for a remote frame, so this // request indicates we need to switch back to the top-level (parent) frame. // We'll first switch to the parent's (global) ChromeMessageBroadcaster, so @@ -2033,15 +1982,14 @@ MarionetteServerConnection.prototype = { while (winEnum.hasMoreElements()) { winEnum.getNext().messageManager.removeDelayedFrameScript(FRAME_SCRIPT); } + this.curBrowser.frameManager.removeMessageManagerListeners(this.globalMessageManager); } - this.removeMessageManagerListeners(this.globalMessageManager); this.switchToGlobalMessageManager(); // reset frame to the top-most frame this.curFrame = null; if (this.mainFrame) { this.mainFrame.focus(); } - this.curBrowser = null; try { this.importedScripts.remove(false); } @@ -2189,60 +2137,50 @@ MarionetteServerConnection.prototype = { this.sendToClient(message.json, -1); break; case "Marionette:switchToFrame": - // Switch to a remote frame. - let frameWindow = Services.wm.getOuterWindowWithId(message.json.win); - let thisFrame = frameWindow.document.getElementsByTagName("iframe")[message.json.frame]; - let mm = thisFrame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager; - - // See if this frame already has our frame script loaded in it; if so, - // just wake it up. - for (let i = 0; i < remoteFrames.length; i++) { - let frame = remoteFrames[i]; - if ((frame.messageManager == mm)) { - this.currentRemoteFrame = frame; - this.currentRemoteFrame.command_id = message.json.command_id; - this.messageManager = frame.messageManager; - this.addMessageManagerListeners(this.messageManager); - this.messageManager.sendAsyncMessage("Marionette:restart", {}); - return; - } - } - - // Load the frame script in this frame, and set the frame's ChromeMessageSender - // as the active message manager. - this.addMessageManagerListeners(mm); - mm.loadFrameScript(FRAME_SCRIPT, true); - this.messageManager = mm; - let aFrame = new MarionetteRemoteFrame(message.json.win, message.json.frame); - aFrame.messageManager = this.messageManager; - aFrame.command_id = message.json.command_id; - remoteFrames.push(aFrame); - this.currentRemoteFrame = aFrame; + this.curBrowser.frameManager.switchToFrame(message); + this.messageManager = this.curBrowser.frameManager.currentRemoteFrame.messageManager.get(); + break; + case "Marionette:switchToModalOrigin": + this.curBrowser.frameManager.switchToModalOrigin(message); + this.messageManager = this.curBrowser.frameManager.currentRemoteFrame.messageManager.get(); break; case "Marionette:switchedToFrame": logger.info("Switched to frame: " + JSON.stringify(message.json)); - this.currentFrameElement = message.json.frameValue; + if (message.json.restorePrevious) { + this.currentFrameElement = this.previousFrameElement; + } + else { + if (message.json.storePrevious) { + // we don't arbitrarily save previousFrameElement, since + // we allow frame switching after modals appear, which would + // override this value and we'd lose our reference + this.previousFrameElement = this.currentFrameElement; + } + this.currentFrameElement = message.json.frameValue; + } break; case "Marionette:register": // This code processes the content listener's registration information // and either accepts the listener, or ignores it let nullPrevious = (this.curBrowser.curFrameId == null); - let listenerWindow = - Services.wm.getOuterWindowWithId(message.json.value); + let listenerWindow = + Services.wm.getOuterWindowWithId(message.json.value); + //go in here if we're already in a remote frame. if (!listenerWindow || (listenerWindow.location.href != message.json.href) && - (this.currentRemoteFrame !== null)) { + (this.curBrowser.frameManager.currentRemoteFrame !== null)) { // The outerWindowID from an OOP frame will not be meaningful to // the parent process here, since each process maintains its own // independent window list. So, it will either be null (!listenerWindow) + // if we're already in a remote frame, // or it will point to some random window, which will hopefully - // cause an href mistmach. Currently this only happens + // cause an href mismatch. Currently this only happens // in B2G for OOP frames registered in Marionette:switchToFrame, so // we'll acknowledge the switchToFrame message here. // XXX: Should have a better way of determining that this message // is from a remote frame. - this.currentRemoteFrame.targetFrameId = this.generateFrameId(message.json.value); - this.sendOk(this.currentRemoteFrame.command_id); + this.curBrowser.frameManager.currentRemoteFrame.targetFrameId = this.generateFrameId(message.json.value); + this.sendOk(this.command_id); } let browserType; @@ -2253,6 +2191,7 @@ MarionetteServerConnection.prototype = { } let reg = {}; if (!browserType || browserType != "content") { + //curBrowser holds all the registered frames in knownFrames reg.id = this.curBrowser.register(this.generateFrameId(message.json.value), listenerWindow); } @@ -2341,11 +2280,11 @@ MarionetteServerConnection.prototype.requestTypes = { * The window whose browser needs to be accessed */ -function BrowserObj(win) { +function BrowserObj(win, server) { this.DESKTOP = "desktop"; this.B2G = "B2G"; this.browser; - this.tab = null; + this.tab = null; //Holds a reference to the created tab, if any this.window = win; this.knownFrames = []; this.curFrameId = null; @@ -2354,6 +2293,10 @@ function BrowserObj(win) { this.newSession = true; //used to set curFrameId upon new session this.elementManager = new ElementManager([SELECTOR, NAME, LINK_TEXT, PARTIAL_LINK_TEXT]); this.setBrowser(win); + this.frameManager = new FrameManager(server); //We should have one FM per BO so that we can handle modals in each Browser + + //register all message listeners + this.frameManager.addMessageManagerListeners(server.messageManager); } BrowserObj.prototype = { From a5e9cf5a3c8a49a24af09c2fa914ce08e1ceb4ed Mon Sep 17 00:00:00 2001 From: Mike Shal Date: Thu, 18 Jul 2013 16:09:03 -0400 Subject: [PATCH 43/43] Bug 874266 - Convert DEFINES to be a dict instead of a list; r=gps --- .../mozbuild/backend/recursivemake.py | 10 +++++++ python/mozbuild/mozbuild/frontend/data.py | 18 +++++++++++++ python/mozbuild/mozbuild/frontend/emitter.py | 6 ++++- .../mozbuild/frontend/sandbox_symbols.py | 26 ++++++++++++++++--- .../mozbuild/mozbuild/test/backend/common.py | 5 ++++ .../test/backend/data/defines/moz.build | 13 ++++++++++ .../backend/data/variable_passthru/moz.build | 2 -- .../test/backend/test_recursivemake.py | 17 +++++++++--- .../test/frontend/data/defines/moz.build | 13 ++++++++++ .../frontend/data/variable-passthru/moz.build | 2 -- .../mozbuild/test/frontend/test_emitter.py | 20 +++++++++++++- 11 files changed, 119 insertions(+), 13 deletions(-) create mode 100644 python/mozbuild/mozbuild/test/backend/data/defines/moz.build create mode 100644 python/mozbuild/mozbuild/test/frontend/data/defines/moz.build diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index d14f883d3de9..b9e3f1d0e36c 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -19,6 +19,7 @@ import mozpack.path as mozpath from .common import CommonBackend from ..frontend.data import ( ConfigFileSubstitution, + Defines, DirectoryTraversal, Exports, GeneratedEventWebIDLFile, @@ -203,6 +204,15 @@ class RecursiveMakeBackend(CommonBackend): backend_file.write('%s := 1\n' % k) else: backend_file.write('%s := %s\n' % (k, v)) + + elif isinstance(obj, Defines): + defines = obj.get_defines() + if defines: + backend_file.write('DEFINES +=') + for define in defines: + backend_file.write(' %s' % define) + backend_file.write('\n') + elif isinstance(obj, Exports): self._process_exports(obj, obj.exports, backend_file) diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 7f388e475714..63116e9d5638 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -153,6 +153,24 @@ class XPIDLFile(SandboxDerived): self.basename = os.path.basename(source) self.module = module +class Defines(SandboxDerived): + """Sandbox container object for DEFINES, which is an OrderedDict. + """ + __slots__ = ('defines') + + def __init__(self, sandbox, defines): + SandboxDerived.__init__(self, sandbox) + self.defines = defines + + def get_defines(self): + for define, value in self.defines.iteritems(): + if value is True: + defstr = define + elif type(value) == int: + defstr = '%s=%s' % (define, value) + else: + defstr = '%s=\'%s\'' % (define, value) + yield('-D%s' % defstr) class Exports(SandboxDerived): """Sandbox container object for EXPORTS, which is a HierarchicalStringList. diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index d37680b502ab..8e5c009bdeaf 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -13,6 +13,7 @@ import mozpack.path as mozpath from .data import ( ConfigFileSubstitution, + Defines, DirectoryTraversal, Exports, GeneratedEventWebIDLFile, @@ -122,7 +123,6 @@ class TreeMetadataEmitter(LoggingMixin): CPPSRCS='CPP_SOURCES', CPP_UNIT_TESTS='CPP_UNIT_TESTS', CSRCS='CSRCS', - DEFINES='DEFINES', EXPORT_LIBRARY='EXPORT_LIBRARY', EXTRA_COMPONENTS='EXTRA_COMPONENTS', EXTRA_JS_MODULES='EXTRA_JS_MODULES', @@ -163,6 +163,10 @@ class TreeMetadataEmitter(LoggingMixin): yield Exports(sandbox, exports, dist_install=not sandbox.get('NO_DIST_INSTALL', False)) + defines = sandbox.get('DEFINES') + if defines: + yield Defines(sandbox, defines) + program = sandbox.get('PROGRAM') if program: yield Program(sandbox, program, sandbox['CONFIG']['BIN_SUFFIX']) diff --git a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py index 1af13d85892e..f4de33907015 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py +++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py @@ -78,10 +78,30 @@ VARIABLES = { This variable contains a list of C source files to compile. """), - 'DEFINES': (StrictOrderingOnAppendList, list, [], - """Compiler defines to declare. + 'DEFINES': (OrderedDict, dict, OrderedDict(), + """Dictionary of compiler defines to declare. - Command line -D flags passed to the compiler. + These are passed in to the compiler as -Dkey='value' for string values, + -Dkey=value for numeric values, or -Dkey if the value is True. Note + that for string values, the outer-level of single-quotes will be + consumed by the shell. If you want to have a string-literal in the + program, the value needs to have double-quotes. + + Example: + DEFINES['NS_NO_XPCOM'] = True + DEFINES['MOZ_EXTENSIONS_DB_SCHEMA'] = 15 + DEFINES['DLL_SUFFIX'] = '".so"' + + This will result in the compiler flags -DNS_NO_XPCOM, + -DMOZ_EXTENSIONS_DB_SCHEMA=15, and -DDLL_SUFFIX='".so"', + respectively. These could also be combined into a single + update: + + DEFINES.update({ + 'NS_NO_XPCOM': True, + 'MOZ_EXTENSIONS_DB_SCHEMA': 15, + 'DLL_SUFFIX': '".so"', + }) """), 'DIRS': (list, list, [], diff --git a/python/mozbuild/mozbuild/test/backend/common.py b/python/mozbuild/mozbuild/test/backend/common.py index a0baede9e7e8..91c20bcae7c7 100644 --- a/python/mozbuild/mozbuild/test/backend/common.py +++ b/python/mozbuild/mozbuild/test/backend/common.py @@ -58,6 +58,11 @@ CONFIGS = { 'non_global_defines': [], 'substs': [], }, + 'defines': { + 'defines': [], + 'non_global_defines': [], + 'substs': [], + }, 'exports': { 'defines': [], 'non_global_defines': [], diff --git a/python/mozbuild/mozbuild/test/backend/data/defines/moz.build b/python/mozbuild/mozbuild/test/backend/data/defines/moz.build new file mode 100644 index 000000000000..240eb70315b5 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/defines/moz.build @@ -0,0 +1,13 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +value = 'xyz' +DEFINES = { + 'FOO': True, +} + +DEFINES['BAZ'] = '"abcd"' +DEFINES.update({ + 'BAR': 7, + 'VALUE': value +}) diff --git a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build index ae8f64171f8c..396737b1b328 100644 --- a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build +++ b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build @@ -6,8 +6,6 @@ MODULE = 'module_name' ASFILES = ['bar.s', 'foo.asm'] -DEFINES = ['-Dbar', '-Dfoo'] - EXTRA_COMPONENTS = ['bar.js', 'foo.js'] EXTRA_PP_COMPONENTS = ['bar.pp.js', 'foo.pp.js'] diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index f97a51dd400a..aa482d580ec6 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -157,10 +157,6 @@ class TestRecursiveMakeBackend(BackendTester): 'CSRCS += bar.c', 'CSRCS += foo.c', ], - 'DEFINES': [ - 'DEFINES += -Dbar', - 'DEFINES += -Dfoo', - ], 'EXTRA_COMPONENTS': [ 'EXTRA_COMPONENTS += bar.js', 'EXTRA_COMPONENTS += foo.js', @@ -390,6 +386,19 @@ class TestRecursiveMakeBackend(BackendTester): ] self.assertEqual(lines, expected) + def test_defines(self): + """Test that DEFINES are written to backend.mk correctly.""" + env = self._consume('defines', RecursiveMakeBackend) + + backend_path = os.path.join(env.topobjdir, 'backend.mk') + lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]] + + var = 'DEFINES' + defines = [val for val in lines if val.startswith(var)] + + expected = ['DEFINES += -DFOO -DBAZ=\'"abcd"\' -DBAR=7 -DVALUE=\'xyz\''] + self.assertEqual(defines, expected) + def test_local_includes(self): """Test that LOCAL_INCLUDES are written to backend.mk correctly.""" env = self._consume('local_includes', RecursiveMakeBackend) diff --git a/python/mozbuild/mozbuild/test/frontend/data/defines/moz.build b/python/mozbuild/mozbuild/test/frontend/data/defines/moz.build new file mode 100644 index 000000000000..240eb70315b5 --- /dev/null +++ b/python/mozbuild/mozbuild/test/frontend/data/defines/moz.build @@ -0,0 +1,13 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +value = 'xyz' +DEFINES = { + 'FOO': True, +} + +DEFINES['BAZ'] = '"abcd"' +DEFINES.update({ + 'BAR': 7, + 'VALUE': value +}) diff --git a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build index 9739c2a4121f..b6ac05209f2c 100644 --- a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build +++ b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build @@ -6,8 +6,6 @@ MODULE = 'module_name' ASFILES += ['fans.asm', 'tans.s'] -DEFINES=['-Dfans', '-Dtans'] - EXTRA_COMPONENTS=['fans.js', 'tans.js'] EXTRA_PP_COMPONENTS=['fans.pp.js', 'tans.pp.js'] diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index f3ee90aaa12e..24f849d694ab 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -14,6 +14,7 @@ from mozbuild.frontend.data import ( DirectoryTraversal, ReaderSummary, VariablePassthru, + Defines, Exports, Program, XpcshellManifests, @@ -132,7 +133,6 @@ class TestEmitterBasic(unittest.TestCase): CMMSRCS=['fans.mm', 'tans.mm'], CSRCS=['fans.c', 'tans.c'], CPP_UNIT_TESTS=['foo.cpp'], - DEFINES=['-Dfans', '-Dtans'], EXPORT_LIBRARY=True, EXTRA_COMPONENTS=['fans.js', 'tans.js'], EXTRA_PP_COMPONENTS=['fans.pp.js', 'tans.pp.js'], @@ -266,5 +266,23 @@ class TestEmitterBasic(unittest.TestCase): self.assertEqual(local_includes, expected) + def test_defines(self): + reader = self.reader('defines') + objs = self.read_topsrcdir(reader) + + defines = {} + for o in objs: + if isinstance(o, Defines): + defines = o.defines + + expected = { + 'BAR': 7, + 'BAZ': '"abcd"', + 'FOO': True, + 'VALUE': 'xyz', + } + + self.assertEqual(defines, expected) + if __name__ == '__main__': main()