JS Function removed after parsing
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 May 2016 20:37:16 +0000 (20:37 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 May 2016 20:37:16 +0000 (20:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149175

Reviewed by Mark Lam.

This bug doesn't happen anymore, but the test case is still useful. This test will fail 1/5 of
the time if we regress.

* js/dom/function-removed-after-parsing-expected.txt: Added.
* js/dom/function-removed-after-parsing.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200518 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/js/dom/function-removed-after-parsing-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/function-removed-after-parsing.html [new file with mode: 0644]

index 90c8b77..61cc42a 100644 (file)
@@ -1,3 +1,16 @@
+2016-05-06  Filip Pizlo  <fpizlo@apple.com>
+
+        JS Function removed after parsing
+        https://bugs.webkit.org/show_bug.cgi?id=149175
+
+        Reviewed by Mark Lam.
+        
+        This bug doesn't happen anymore, but the test case is still useful. This test will fail 1/5 of
+        the time if we regress.
+
+        * js/dom/function-removed-after-parsing-expected.txt: Added.
+        * js/dom/function-removed-after-parsing.html: Added.
+
 2016-05-06  Jer Noble  <jer.noble@apple.com>
 
         Muted media elements should be allowed to autoplay, even if RequireUserGestureForAudioRateChange is set.
diff --git a/LayoutTests/js/dom/function-removed-after-parsing-expected.txt b/LayoutTests/js/dom/function-removed-after-parsing-expected.txt
new file mode 100644 (file)
index 0000000..a6438f3
--- /dev/null
@@ -0,0 +1,2 @@
+window.CSS.escape still here
+
diff --git a/LayoutTests/js/dom/function-removed-after-parsing.html b/LayoutTests/js/dom/function-removed-after-parsing.html
new file mode 100644 (file)
index 0000000..136bdde
--- /dev/null
@@ -0,0 +1,123 @@
+<html>
+<!--
+NOTE: This intentionally does not use description() and does not include js-test-post because
+doing either of those things made the bug go away.
+-->
+  <script src="../../resources/js-test-pre.js"></script>
+  <script type='text/javascript'>
+/*! https://mths.be/cssescape v1.1.0 by @mathias | MIT license */
+;(function(root) {
+
+       if (!root.CSS) {
+               root.CSS = {};
+       }
+
+       var CSS = root.CSS;
+
+       var InvalidCharacterError = function(message) {
+               this.message = message;
+       };
+       InvalidCharacterError.prototype = new Error;
+       InvalidCharacterError.prototype.name = 'InvalidCharacterError';
+
+       if (!CSS.escape) {
+               // https://drafts.csswg.org/cssom/#serialize-an-identifier
+               CSS.escape = function(value) {
+                       var string = String(value);
+                       var length = string.length;
+                       var index = -1;
+                       var codeUnit;
+                       var result = '';
+                       var firstCodeUnit = string.charCodeAt(0);
+                       while (++index < length) {
+                               codeUnit = string.charCodeAt(index);
+                               // Note: there\92s no need to special-case astral symbols, surrogate
+                               // pairs, or lone surrogates.
+
+                               // If the character is NULL (U+0000), then throw an
+                               // `InvalidCharacterError` exception and terminate these steps.
+                               if (codeUnit == 0x0000) {
+                                       throw new InvalidCharacterError(
+                                               'Invalid character: the input contains U+0000.'
+                                       );
+                               }
+
+                               if (
+                                       // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
+                                       // U+007F, [\85]
+                                       (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
+                                       // If the character is the first character and is in the range [0-9]
+                                       // (U+0030 to U+0039), [\85]
+                                       (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
+                                       // If the character is the second character and is in the range [0-9]
+                                       // (U+0030 to U+0039) and the first character is a `-` (U+002D), [\85]
+                                       (
+                                               index == 1 &&
+                                               codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
+                                               firstCodeUnit == 0x002D
+                                       )
+                               ) {
+                                       // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
+                                       result += '\\' + codeUnit.toString(16) + ' ';
+                                       continue;
+                               }
+
+                               if (
+                                       // If the character is the first character and is a `-` (U+002D), and
+                                       // there is no second character, [\85]
+                                       index == 0 &&
+                                       length == 1 &&
+                                       codeUnit == 0x002D
+                               ) {
+                                       result += '\\' + string.charAt(index);
+                                       continue;
+                               }
+
+                               // If the character is not handled by one of the above rules and is
+                               // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
+                               // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
+                               // U+005A), or [a-z] (U+0061 to U+007A), [\85]
+                               if (
+                                       codeUnit >= 0x0080 ||
+                                       codeUnit == 0x002D ||
+                                       codeUnit == 0x005F ||
+                                       codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
+                                       codeUnit >= 0x0041 && codeUnit <= 0x005A ||
+                                       codeUnit >= 0x0061 && codeUnit <= 0x007A
+                               ) {
+                                       // the character itself
+                                       result += string.charAt(index);
+                                       continue;
+                               }
+
+                               // Otherwise, the escaped character.
+                               // https://drafts.csswg.org/cssom/#escape-a-character
+                               result += '\\' + string.charAt(index);
+
+                       }
+                       return result;
+               };
+       }
+
+}(typeof global != 'undefined' ? global : this));
+
+  </script>
+  <script type='text/javascript'>
+    try {
+      testRunner.dumpAsText(window.enablePixelTesting);
+      testRunner.waitUntilDone();
+    } catch (e) { }
+    if (!window.CSS.escape) {
+      debug('window.CSS.escape not loaded');
+    }
+    setTimeout(function() {
+      if (window.CSS.escape)
+        debug("window.CSS.escape still here");
+      else
+        debug('window.CSS.escape missing in event');
+      try {
+        testRunner.notifyDone();
+      } catch (e) { }
+    },50);
+  </script>
+</html>