| Index: chrome/test/data/extensions/api_test/mutation_observers/background.js
|
| diff --git a/chrome/test/data/extensions/api_test/mutation_observers/background.js b/chrome/test/data/extensions/api_test/mutation_observers/background.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5aa1454f1be6264c5a6a8d11ae5edc3acf6fb997
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/mutation_observers/background.js
|
| @@ -0,0 +1,37 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +window.addEventListener('DOMContentLoaded', function() {
|
| + var body = document.body;
|
| + var div = body.appendChild(document.createElement('div'));
|
| + var input1 = body.appendChild(document.createElement('input'));
|
| + var input2 = body.appendChild(document.createElement('input'));
|
| +
|
| + input1.focus();
|
| + input1.addEventListener('blur', function() {
|
| + div.setAttribute('baz', 'bat');
|
| + });
|
| +
|
| + var success = false;
|
| + var mutationsDelivered = false;
|
| +
|
| + var MutationObserver = MutationObserver || WebKitMutationObserver;
|
| + var observer = new MutationObserver(function() {
|
| + mutationsDelivered = true;
|
| + if (success)
|
| + chrome.test.succeed();
|
| + });
|
| + observer.observe(document, { subtree: true, attributes: true });
|
| +
|
| + // The getAll callback should be counted as a V8RecursionScope and cause
|
| + // the delivery of MutationRecords to be delayed until it has exited.
|
| + chrome.windows.getAll(function() {
|
| + div.setAttribute('foo', 'bar');
|
| + input2.focus();
|
| + if (mutationsDelivered)
|
| + chrome.test.fail();
|
| + else
|
| + success = true;
|
| + });
|
| +});
|
|
|