Commit e7c12ca3 authored by Johnny(Jianning) Ding's avatar Johnny(Jianning) Ding Committed by Commit Bot

Check script setting before invoking the mutation observer handler.

Bug: 848086
Change-Id: Icf22bbb2f3c82bdcb6ecdadf55967401630fe5fb
Reviewed-on: https://chromium-review.googlesource.com/1085896Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Commit-Queue: Johnny Ding <jnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564302}
parent 99fa9000
(async function(testRunner) {
var {page, session, dp} =
await testRunner.startHTML(`
<body><script>
count = 0;
var observer = new MutationObserver(() => {count++;});
observer.observe(document.body, {childList: true});
</script></body>
`, 'Tests mutation observer invocation.');
async function triggerMutation() {
await session.evaluate(`document.body.appendChild(document.createTextNode('ha'))`);
let result = await session.evaluate(`count`);
testRunner.log(`Count: ${result}.`);
}
await triggerMutation();
await dp.Emulation.setScriptExecutionDisabled({value: true});
await triggerMutation();
testRunner.completeTest();
})
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/bindings/core/v8/exception_state.h" #include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_mutation_callback.h" #include "third_party/blink/renderer/bindings/core/v8/v8_mutation_callback.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/mutation_observer_init.h" #include "third_party/blink/renderer/core/dom/mutation_observer_init.h"
#include "third_party/blink/renderer/core/dom/mutation_observer_registration.h" #include "third_party/blink/renderer/core/dom/mutation_observer_registration.h"
#include "third_party/blink/renderer/core/dom/mutation_record.h" #include "third_party/blink/renderer/core/dom/mutation_record.h"
...@@ -285,8 +286,13 @@ HeapHashSet<Member<Node>> MutationObserver::GetObservedNodes() const { ...@@ -285,8 +286,13 @@ HeapHashSet<Member<Node>> MutationObserver::GetObservedNodes() const {
} }
bool MutationObserver::ShouldBeSuspended() const { bool MutationObserver::ShouldBeSuspended() const {
const ExecutionContext* execution_context = delegate_->GetExecutionContext(); ExecutionContext* execution_context = delegate_->GetExecutionContext();
return execution_context && execution_context->IsContextPaused(); if (!execution_context)
return false;
Document* document = ToDocument(execution_context);
DCHECK(document);
return !document->CanExecuteScripts(kAboutToExecuteScript) ||
execution_context->IsContextPaused();
} }
void MutationObserver::CancelInspectorAsyncTasks() { void MutationObserver::CancelInspectorAsyncTasks() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment