This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SandboxGlobalProxy { | |
constructor(sharedState) { | |
const iframe = document.createElement("iframe", { url: "about:blank" }); | |
iframe.style.display = "none"; | |
document.body.appendChild(iframe); | |
const sandboxGlobal = iframe.contentWindow; | |
return new Proxy(sandboxGlobal, { | |
has: (target, prop) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = "foo1"; | |
const ctx = { | |
func: variable => { | |
console.log(variable); | |
} | |
}; | |
function withedYourCode(code) { | |
code = "with(shadow) {" + code + "}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = "foo1"; | |
const ctx = { | |
func: variable => { | |
console.log(variable); | |
}, | |
foo: "f1" | |
}; | |
function veryPoorSandbox(code, ctx) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.document = null; | |
console.log(window.document); | |
delete window.document | |
console.log(window.document); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReflectDemo reflectDemo = new ReflectDemo(); | |
(1)Class<ReflectDemo> reflectDemoClass = ReflectDemo.class; | |
(2)Class<?> aClass = Class.forName ("com.omgzui.springtransaction.transactiondemo.reflectdemo.ReflectDemo"); | |
(3)Class<? extends Class> aClass = reflectDemoClass.getClass (); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReflectDemo { | |
public static void main (String[] args) throws IllegalAccessException, InstantiationException { | |
proxyObject(); | |
newObject(); | |
} | |
public static void newObject(){ | |
long startTime = System.currentTimeMillis (); | |
int i; | |
for (i = 0; i < 100000000; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReflectDemo reflectDemo = new ReflectDemo(); | |
(1)Class<ReflectDemo> reflectDemoClass = ReflectDemo.class; | |
(2)Class<?> aClass = Class.forName ("com.omgzui.springtransaction.transactiondemo.reflectdemo.ReflectDemo"); | |
(3)Class<? extends Class> aClass = reflectDemoClass.getClass (); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const idol = { | |
name: 'Tom', | |
phone: 10086, | |
price: 1000000 | |
} | |
const agent = new Proxy(idol, { | |
get: function(target) { | |
return 'phone:10010'; | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Adapter { | |
test() { | |
return 'old'; | |
} | |
} | |
class Target { | |
constructor() { | |
this.adapter = new Adapter(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function info(target) { | |
target.prototype.name = 'Tom'; | |
target.prototype.age = 10; | |
} | |
@info | |
class Man {} | |
let man = new Man(); | |
man.name; |