Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1333)

Side by Side Diff: chrome/test/data/extensions/app_forbidden_apis/onbeforeunload/background.js

Issue 1744623002: [Extensions] Update web API cloberring for platform apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 'use strict';
6
7 var didRun = sessionStorage.didRun;
8
9 function beforeUnload() {
10 chrome.test.fail();
11 }
12
13 try {
14 delete window.onbeforeunload;
15 window.onbeforeunload = beforeUnload;
16 } catch (e) {}
17
18 try {
19 window.addEventListener('beforeunload', beforeUnload);
20 } catch (e) {}
21
22 try {
23 var beforeUnloadTricky = {
24 toString: function() {
25 beforeUnloadTricky.toString = function() { return 'beforeunload'; };
26 return 'something not beforeunload';
27 }
28 };
29 window.addEventListener(beforeUnloadTricky, beforeUnload);
30 } catch (e) {}
31
32 if (!didRun) {
33 sessionStorage.didRun = true;
34 location.reload();
35 } else {
36 chrome.test.succeed();
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698