diff options
author | emaxx <emaxx@chromium.org> | 2015-05-29 04:26:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-29 11:26:31 +0000 |
commit | e70f5e1d286a200d420a996fcc2ff7fa7a2780a2 (patch) | |
tree | a4d700fca0037a858e5def87fb621d8924903746 /ppapi/tests | |
parent | 7a9e97c09150725748953ca9e1cf118d56d35f55 (diff) | |
download | chromium_src-e70f5e1d286a200d420a996fcc2ff7fa7a2780a2.zip chromium_src-e70f5e1d286a200d420a996fcc2ff7fa7a2780a2.tar.gz chromium_src-e70f5e1d286a200d420a996fcc2ff7fa7a2780a2.tar.bz2 |
Keep event page alive when there's some Pepper plugin on it.
BUG=472532
Review URL: https://codereview.chromium.org/1117023002
Cr-Commit-Position: refs/heads/master@{#331945}
Diffstat (limited to 'ppapi/tests')
-rw-r--r-- | ppapi/tests/extensions/extensions.gyp | 20 | ||||
-rw-r--r-- | ppapi/tests/extensions/load_unload/background.js | 36 | ||||
-rw-r--r-- | ppapi/tests/extensions/load_unload/ext_icon.png | bin | 0 -> 1578 bytes | |||
-rw-r--r-- | ppapi/tests/extensions/load_unload/load_unload.cc | 25 | ||||
-rw-r--r-- | ppapi/tests/extensions/load_unload/manifest.json | 14 |
5 files changed, 95 insertions, 0 deletions
diff --git a/ppapi/tests/extensions/extensions.gyp b/ppapi/tests/extensions/extensions.gyp index 6d85a94..37b2316 100644 --- a/ppapi/tests/extensions/extensions.gyp +++ b/ppapi/tests/extensions/extensions.gyp @@ -27,6 +27,26 @@ }, }, { + 'target_name': 'ppapi_tests_extensions_load_unload', + 'type': 'none', + 'variables': { + 'nexe_target': 'ppapi_tests_extensions_load_unload', + # Only newlib build is used in tests, no need to build others. + 'build_newlib': 1, + 'build_glibc': 0, + 'build_pnacl_newlib': 0, + 'nexe_destination_dir': 'test_data/ppapi/tests/extensions/load_unload', + 'sources': [ + 'load_unload/load_unload.cc', + ], + 'test_files': [ + 'load_unload/background.js', + 'load_unload/ext_icon.png', + 'load_unload/manifest.json', + ], + }, + }, + { 'target_name': 'ppapi_tests_extensions_media_galleries', 'type': 'none', 'variables': { diff --git a/ppapi/tests/extensions/load_unload/background.js b/ppapi/tests/extensions/load_unload/background.js new file mode 100644 index 0000000..a77dcd0 --- /dev/null +++ b/ppapi/tests/extensions/load_unload/background.js @@ -0,0 +1,36 @@ +// Copyright 2015 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. + +var nacl = null; + +function loadNaClModule() { + nacl = document.createElement('embed'); + nacl.addEventListener('load', onNaClModuleLoaded, true); + nacl.type = 'application/x-nacl'; + nacl.width = 0; + nacl.height = 0; + nacl.src = 'ppapi_tests_extensions_load_unload.nmf'; + document.body.appendChild(nacl); + + // Request the offsetTop property to force a relayout. As of Apr 10, 2014 + // this is needed if the module is being loaded in a background page (see + // crbug.com/350445). + nacl.offsetTop; +} + +function detachNaClModule() { + document.body.removeChild(nacl); + nacl = null; +} + +function onNaClModuleLoaded() { + chrome.test.sendMessage("nacl_module_loaded"); +} + +chrome.browserAction.onClicked.addListener(function(tab) { + if (!nacl) + loadNaClModule(); + else + detachNaClModule(); +}); diff --git a/ppapi/tests/extensions/load_unload/ext_icon.png b/ppapi/tests/extensions/load_unload/ext_icon.png Binary files differnew file mode 100644 index 0000000..e3cdb8a --- /dev/null +++ b/ppapi/tests/extensions/load_unload/ext_icon.png diff --git a/ppapi/tests/extensions/load_unload/load_unload.cc b/ppapi/tests/extensions/load_unload/load_unload.cc new file mode 100644 index 0000000..f16abbc --- /dev/null +++ b/ppapi/tests/extensions/load_unload/load_unload.cc @@ -0,0 +1,25 @@ +// Copyright 2015 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. + +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" + +namespace { + +class Module : public pp::Module { + public: + virtual pp::Instance* CreateInstance(PP_Instance instance) { + return new pp::Instance(instance); + } +}; + +} // namespace + +namespace pp { + +Module* CreateModule() { + return new ::Module(); +} + +} // namespace pp diff --git a/ppapi/tests/extensions/load_unload/manifest.json b/ppapi/tests/extensions/load_unload/manifest.json new file mode 100644 index 0000000..33d12da --- /dev/null +++ b/ppapi/tests/extensions/load_unload/manifest.json @@ -0,0 +1,14 @@ +{ + "name": "Lazy background wait for NaCl test", + "description": "Tests that a lazy background page stays alive while a NaCl module exists in its DOM", + "version": "0", + "manifest_version": 2, + "background": { + "scripts": ["background.js"], + "persistent": false + }, + "browser_action": { + "default_icon" : "ext_icon.png", + "default_title": "Open Extensions window" + } +} |