Update V8 to version 4.7.19.
[chromium-blink-merge.git] / ppapi / tests / extensions / load_unload / background.js
bloba77dcd0103d28183b2930ab934ab830e89976da7
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var nacl = null;
7 function loadNaClModule() {
8 nacl = document.createElement('embed');
9 nacl.addEventListener('load', onNaClModuleLoaded, true);
10 nacl.type = 'application/x-nacl';
11 nacl.width = 0;
12 nacl.height = 0;
13 nacl.src = 'ppapi_tests_extensions_load_unload.nmf';
14 document.body.appendChild(nacl);
16 // Request the offsetTop property to force a relayout. As of Apr 10, 2014
17 // this is needed if the module is being loaded in a background page (see
18 // crbug.com/350445).
19 nacl.offsetTop;
22 function detachNaClModule() {
23 document.body.removeChild(nacl);
24 nacl = null;
27 function onNaClModuleLoaded() {
28 chrome.test.sendMessage("nacl_module_loaded");
31 chrome.browserAction.onClicked.addListener(function(tab) {
32 if (!nacl)
33 loadNaClModule();
34 else
35 detachNaClModule();
36 });