 Chromium Code Reviews
 Chromium Code Reviews Issue 2810543002:
  [tests] Convert a detached typed array to a null string  (Closed)
    
  
    Issue 2810543002:
  [tests] Convert a detached typed array to a null string  (Closed) 
  | Index: third_party/WebKit/LayoutTests/fast/dom/Window/window-postmessage-args.html | 
| diff --git a/third_party/WebKit/LayoutTests/fast/dom/Window/window-postmessage-args.html b/third_party/WebKit/LayoutTests/fast/dom/Window/window-postmessage-args.html | 
| index 7f2eeb862d6f04d195080454b4b5b4c2425f5aeb..ec936fb5008f3e96e82d3cb3c3666c1939d5e553 100644 | 
| --- a/third_party/WebKit/LayoutTests/fast/dom/Window/window-postmessage-args.html | 
| +++ b/third_party/WebKit/LayoutTests/fast/dom/Window/window-postmessage-args.html | 
| @@ -35,14 +35,21 @@ function tryPostMessageFunction(postMessageFunction, first, second, third, shoul | 
| pass = shouldFail; | 
| reason = ": threw exception " + e; | 
| } | 
| + // we cannot convert detached typed arrays into strings, thus | 
| + // manually convert detached typed arrays into a null string. | 
| + if (first instanceof Int8Array && first.byteLength === 0) | 
| + first = ""; | 
| + for (var i = 0; third && i < third.length; i++) { | 
| + if (third[i] instanceof Int8Array && third[i].byteLength === 0) | 
| + third[i] = ""; | 
| + } | 
| 
Dan Ehrenberg
2017/04/11 10:20:22
Nit: this code could be slightly cleaned up, and c
 
Choongwoo Han
2017/04/11 12:48:23
Done.
 | 
| if (pass) | 
| testPassed("Posting message ('" + first + "', " + third + ")" + reason); | 
| else | 
| testFailed("Posting message ('" + first + "', " + third + ")" + reason); | 
| } | 
| -function tryPostMessage(first, second, third, shouldFail) { | 
| - tryPostMessageFunction(window.postMessage, first, second, third, shouldFail); | 
| +function tryPostMessage(first, second, third, shouldFail) { tryPostMessageFunction(window.postMessage, first, second, third, shouldFail); | 
| 
Dan Ehrenberg
2017/04/11 10:20:22
Nit: Undo this whitespace change.
 
Choongwoo Han
2017/04/11 12:48:23
Done.
 | 
| } | 
| document.getElementById("description").innerHTML = "Test that the second argument of window.postMessage is ignored or triggers an error if it is not a message port. You should see PASS message '1' through '7', followed by 'done', with messages 4-7 received below.<br><br>"; |